Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable SSO Across Applications #17

Open
tomjackman opened this issue Mar 15, 2018 · 2 comments
Open

Enable SSO Across Applications #17

tomjackman opened this issue Mar 15, 2018 · 2 comments

Comments

@tomjackman
Copy link
Contributor

Reference the AppAuth-iOS Master Branch which has Custom Browser Support in the Podfile.

pod 'AppAuth', :git => 'https://github.com/openid/AppAuth-iOS.git', :branch => 'master'

Allow Custom Browsers to be Opened

In the info.plist add:

<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>googlechromes</string>
		<string>opera-https</string>
		<string>firefox</string>
	</array>

Setup the App Identifier for the Browser to Redirect Back To

In the info.plist update to:

 			<key>CFBundleURLSchemes</key>
 			<array>
				<string>com.redhat.secure-ios-app.sso2</string>
 			</array>

Note, this should match what is defined as the app Id. (In Xcode click the project name in the top left, and the Bundle Identifier can be seen)

Updating the AuthenticationService logic

Update the redirect URL:
let REDIRECT_URL = URL(string:"com.redhat.secure-ios-app.sso2:/callback") Code

Update the authCall to include using the Safari browser or other: Code

let externalUserAgent = OIDExternalUserAgentIOSCustomBrowser.customBrowserSafari();

// this will automatically exchange the token to get the user info
self.currentAuthorisationFlow = OIDAuthState.authState(byPresenting: oidAuthRequest, externalUserAgent: externalUserAgent) {
...
  1. Run the app and check auth works.
  2. Update all the URL's above to use com.redhat.secure-ios-app.sso to mimic a second app. Ensure that you also change the app ID for the project too. (In Xcode click the project name in the top left, and the Bundle Identifier can be seen). Then try the normal SSO flow and it should work.

I have added the code changes in my master branch.

@wei-lee
Copy link
Contributor

wei-lee commented Mar 15, 2018

@TommyJ1994 so will this actually use the Safari browser then?

@tomjackman
Copy link
Contributor Author

@wei-lee Yes, works fine with Safari. You can use other browsers like so:

let chromeBrowser = OIDExternalUserAgentIOSCustomBrowser.customBrowserChrome();
let firefoxBrowser = OIDExternalUserAgentIOSCustomBrowser.customBrowserFirefox();
let operaBrowser = OIDExternalUserAgentIOSCustomBrowser.customBrowserOpera();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants