Skip to content

Commit 637b6c4

Browse files
Update Readme (#306)
* Update Readme * Add a note about Swift Authn SDK
1 parent 949a8ca commit 637b6c4

File tree

1 file changed

+34
-69
lines changed

1 file changed

+34
-69
lines changed

README.md

+34-69
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
> This is a new version of this SDK, the new pod name is [OktaOidc](https://cocoapods.org/pods/OktaOidc). The old [OktaAuth](https://cocoapods.org/pods/OktaAuth) pod is now deprecated.
1414
15-
This library is a swift wrapper around the [AppAuth-iOS](https://github.com/openid/AppAuth-iOS) objective-c code for communicating with Okta as an OAuth 2.0 + OpenID Connect provider, and follows current best practice for native apps using [Authorization Code Flow + PKCE](https://developer.okta.com/authentication-guide/implementing-authentication/auth-code-pkce).
15+
This library is a Swift wrapper around the [AppAuth-iOS](https://github.com/openid/AppAuth-iOS) Objective-C code for communicating with Okta as an OAuth 2.0 + OpenID Connect provider, and follows current best practice for native apps using [Authorization Code Flow + PKCE](https://developer.okta.com/authentication-guide/implementing-authentication/auth-code-pkce).
1616

17-
You can learn more on the [Okta + iOS](https://developer.okta.com/code/ios/) page in our documentation. You can also download our [sample application](https://github.com/okta/samples-ios/tree/master/browser-sign-in)
17+
You can learn more on the [Okta + iOS](https://developer.okta.com/code/ios/) page in our documentation. You can also download our [sample application](https://github.com/okta/samples-ios/tree/master/browser-sign-in).
1818

1919
**Table of Contents**
2020

@@ -41,6 +41,7 @@ You can learn more on the [Okta + iOS](https://developer.okta.com/code/ios/) pag
4141
- [Running Tests](#running-tests)
4242
- [Modify network requests](#modify-network-requests)
4343
- [Known issues](#known-issues)
44+
- [Contributing](#contributing)
4445

4546
<!-- /TOC -->
4647

@@ -53,13 +54,15 @@ You'll also need:
5354
- An Okta account, called an _organization_ (sign up for a free [developer organization](https://developer.okta.com/signup/) if you need one).
5455
- An Okta Application, configured as a Native App. This is done from the Okta Developer Console and you can find instructions [here](https://developer.okta.com/authentication-guide/implementing-authentication/auth-code-pkce). When following the wizard, use the default properties. They are designed to work with our sample applications.
5556

57+
**Note:** If you would like to use your own in-app user interface instead of the web browser, you can do so by using our [Swift Authentication SDK](https://github.com/okta/okta-auth-swift).
58+
5659
## Supported Platforms
5760

5861
### iOS
5962
Okta OIDC supports iOS 11 and above.
6063

6164
### macOS
62-
Okta OIDC supports macOS (OS X) 10.10 and above. Library supports both custom schemes; a loopback HTTP redirects via a small embedded server.
65+
Okta OIDC supports macOS (OS X) 10.14 and above. Library supports both custom schemes; a loopback HTTP redirects via a small embedded server.
6366

6467
## Install
6568

@@ -93,6 +96,12 @@ To integrate this SDK into your Xcode project using [Carthage](https://github.co
9396
github "okta/okta-oidc-ios"
9497
```
9598

99+
Then install it into your project:
100+
101+
`carthage update --use-xcframeworks`
102+
103+
**Note:** Make sure Carthage version is 0.37.0 or higher. Otherwise, Carthage can fail.
104+
96105
## Usage Guide
97106

98107
For an overview of this library's features and authentication flows, check out [our developer docs](https://developer.okta.com/code/ios).
@@ -151,7 +160,7 @@ The easiest way is to create a property list in your application's bundle. By de
151160

152161
### Configuration object
153162

154-
Alternatively, you can create a configuration object ( `OktaOidcConfig`) from dictionary with the required values:
163+
Alternatively, you can create a configuration object (`OktaOidcConfig`) from dictionary with the required values:
155164

156165
```swift
157166
let configuration = OktaOidcConfig(with: [
@@ -205,7 +214,7 @@ oktaOidc.signInWithBrowser(from: viewController, additionalParameters: ["idp": "
205214
// stateManager.refreshToken
206215
}
207216
```
208-
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/WelcomeViewController.swift#L35-L46)
217+
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/WelcomeViewController.swift#L35-L46).
209218

210219
#### macOS
211220
```swift
@@ -240,7 +249,7 @@ oktaOidc.signOutOfOkta(authStateManager, from: viewController) { error in
240249
}
241250
}
242251
```
243-
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/SignInViewController.swift#L62-L74)
252+
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/SignInViewController.swift#L62-L74).
244253

245254
#### macOS
246255
```swift
@@ -260,12 +269,12 @@ oktaOidc.signOutOfOkta(authStateManager: authStateManager, redirectServerConfigu
260269

261270
This method helps to perform a multi-step sign-out flow. The method provides options that you want to perform and the SDK runs the options as a batch.
262271
The available options are:
263-
- revokeAccessToken - SDK revokes access token
264-
- revokeRefreshToken - SDK revokes refresh token
265-
- removeTokensFromStorage - SDK removes tokens from the secure storage
266-
- signOutFromOkta - SDK calls [`signOutOfOkta`](#signoutofokta)
267-
- revokeTokensOptions - revokes access and refresh tokens
268-
- allOptions - revokes tokens, signs out from Okta, and removes tokens from the secure storage
272+
- `revokeAccessToken` - SDK revokes access token
273+
- `revokeRefreshToken` - SDK revokes refresh token
274+
- `removeTokensFromStorage` - SDK removes tokens from the secure storage
275+
- `signOutFromOkta` - SDK calls [`signOutOfOkta`](#signoutofokta)
276+
- `revokeTokensOptions` - revokes access and refresh tokens
277+
- `allOptions` - revokes tokens, signs out from Okta, and removes tokens from the secure storage
269278

270279
The order of operations performed by the SDK:
271280
1. Revoke the access token, if the option is set. If this step fails step 3 will be omitted.
@@ -333,7 +342,7 @@ oktaOidc.authenticate(withSessionToken: token) { stateManager, error in
333342
// stateManager.refreshToken
334343
}
335344
```
336-
Sample app [example](https://github.com/okta/samples-ios/blob/master/custom-sign-in/OktaNativeLogin/UserProfile/UserProfileViewController.swift#L39-L50)
345+
Sample app [example](https://github.com/okta/samples-ios/blob/master/custom-sign-in/OktaNativeLogin/UserProfile/UserProfileViewController.swift#L39-L50).
337346

338347
### stateManager
339348

@@ -352,9 +361,9 @@ oktaOidc.signInWithBrowser(from: self) { stateManager, error in
352361
stateManager.writeToSecureStorage()
353362
}
354363
```
355-
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/WelcomeViewController.swift#L44)
364+
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/WelcomeViewController.swift#L44).
356365

357-
To retrieve stored manager call `readFromSecureStorage(for: )` and pass here Okta configuration that corresponds to a manager you are interested in.
366+
To retrieve stored manager call `readFromSecureStorage(for:)` and pass here Okta configuration that corresponds to a manager you are interested in.
358367

359368
```swift
360369
guard let stateManager = OktaOidcStateManager.readFromSecureStorage(for: oktaConfig) else {
@@ -366,7 +375,7 @@ guard let stateManager = OktaOidcStateManager.readFromSecureStorage(for: oktaCon
366375
// stateManager.idToken
367376
// stateManager.refreshToken
368377
```
369-
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/AppDelegate.swift#L32)
378+
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/AppDelegate.swift#L32).
370379

371380
**Note:** In OktaOidc SDK 3.0 we added support for multiple Oauth 2.0 accounts. So developer can use Okta endpoint, social endpoint and others in one application. Therefore `OktaOidcStateManager` is stored in keychain using composite key constructed based on configuration. For backward compatibility there is a method `readFromSecureStorage()` that tries to read `OktaOidcStateManager` stored on a legacy way, so user could retrieve previously stored `OktaOidcStateManager` after switching to a newer version of SDK.
372381

@@ -384,7 +393,7 @@ stateManager?.introspect(token: accessToken, callback: { payload, error in
384393
print("Is token valid? \(isValid)")
385394
})
386395
```
387-
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/TokensViewController.swift#L38-L47)
396+
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/TokensViewController.swift#L38-L47).
388397

389398
#### renew
390399

@@ -400,7 +409,7 @@ stateManager?.renew { newAccessToken, error in
400409
// renewed TokenManager
401410
}
402411
```
403-
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/TokensViewController.swift#L51-L59)
412+
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/TokensViewController.swift#L51-L59).
404413

405414
#### revoke
406415

@@ -416,7 +425,7 @@ stateManager?.revoke(accessToken) { response, error in
416425
// Token was revoked
417426
}
418427
```
419-
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/TokensViewController.swift#L65-L75)
428+
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/TokensViewController.swift#L65-L75).
420429

421430
#### getUser
422431

@@ -432,7 +441,7 @@ stateManager?.getUser { response, error in
432441
// JSON response
433442
}
434443
```
435-
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/SignInViewController.swift#L28-L38)
444+
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/SignInViewController.swift#L28-L38).
436445

437446
#### clear
438447

@@ -442,7 +451,7 @@ Removes the local authentication state by removing cached tokens in the keychain
442451
```swift
443452
stateManager.clear()
444453
```
445-
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/SignInViewController.swift#L70)
454+
Sample app [example](https://github.com/okta/samples-ios/blob/master/browser-sign-in/OktaBrowserSignIn/SignInViewController.swift#L70).
446455

447456
## Development
448457

@@ -462,7 +471,7 @@ export LOGOUT_REDIRECT_URI={logoutRedirectUri}
462471
bash ./scripts/build-and-test.sh
463472
```
464473

465-
**Note:** *You may need to update the emulator device to match your Xcode version*
474+
**Note:** *You may need to update the emulator device to match your Xcode version.*
466475

467476
## Modify network requests
468477

@@ -505,53 +514,9 @@ Known iOS issue where iOS doesn't provide any good ways to terminate active auth
505514

506515
You can also consider the following workarounds:
507516
- Use `noSSO` option in OIDC configuration object if you don't need SSO capabilites. Also note that this option works only on iOS 13+ versions
508-
- Fork repository and change user-agent implementation(`OIDExternalUserAgentIOS.m`) to use `SFSafariViewController` only. Some pitfalls of this approach described [here](https://github.com/okta/okta-oidc-ios/issues/181)
509-
510-
### Carthage fails on Xcode 12
511-
Carthage throws the error when you install the dependencies with the command `carthage update`. The issue happens only on Xcode 12 and higher versions:
512-
513-
```bash
514-
Build Failed
515-
Task failed with exit code 1:
516-
/usr/bin/xcrun lipo -create /Users/user/Library/Caches/org.carthage.CarthageKit/DerivedData/12.4_12D4e/okta-oidc-ios/3.10.1/Build/Intermediates.noindex/ArchiveIntermediates/okta-oidc/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/OktaOidc.framework/OktaOidc /Users/user/Library/Caches/org.carthage.CarthageKit/DerivedData/12.4_12D4e/okta-oidc-ios/3.10.1/Build/Products/Release-iphonesimulator/OktaOidc.framework/OktaOidc -output /Users/user/{ProjectName}/Carthage/Build/iOS/OktaOidc.framework/OktaOidc
517-
518-
This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/2x/q10zv0gx4112thm7dd13szmm0000gn/T/carthage-xcodebuild.YaJjLW.log
519-
```
520-
521-
The reason is that Xcode 12 introduced support of the Apple Silicon and Xcode generates duplicated architectures in frameworks. XCFrameworks are still not supported by Carthage, therefore a workaround should be used.
522-
523-
##### Solution #1: XCFrameworks
517+
- Fork repository and change user-agent implementation(`OIDExternalUserAgentIOS.m`) to use `SFSafariViewController` only. Some pitfalls of this approach described [here](https://github.com/okta/okta-oidc-ios/issues/181).
524518

525-
You should update Carthage to the version 0.37.0 or higher.
519+
## Contributing
526520

527-
1. Run in Terminal the following command:
528-
```bash
529-
brew upgrade carthage
530-
```
531-
2. Make sure the version is correct:
532-
```bash
533-
carthage version
534-
```
535-
3. Navigate through Terminal to project folder and run:
536-
```bash
537-
carthage update --use-xcframeworks
538-
```
539-
4. Open `General` settings tab in Xcode, in the `Frameworks, Libraries, and Embedded Content` section, drag and drop each XCFramework you want to use from the `Carthage/Build` folder.
540-
541-
> If your existing project is based on discrete framework bundles and you may want to migrate to XCFrameworks, then follow [Carthage migration documentation](https://github.com/Carthage/Carthage#migrating-a-project-from-framework-bundles-to-xcframeworks).
542-
543-
##### Solution #2: Workaround script
544-
545-
Launch Carthage via [the script](/scripts/carthage-xcode-12.sh), it will remove duplicated architectures and produce correct framework bundles.
546-
547-
1. Put the script somewhere to your `PATH` (e.g.: `/usr/local/bin/carthage.sh`).
548-
2. Make the script executable, so open your Terminal and execute:
549-
```sh
550-
chmod +x /{path_to_script_folder}/carthage.sh
551-
```
552-
3. Run the script whenever you want to use Carthage:
553-
```sh
554-
carthage.sh update
555-
```
521+
We welcome contributions to all of our open-source packages. Please, see the [contribution guide](CONTRIBUTING.md) to understand how to structure a contribution.
556522

557-
For more information, follow [official Carthage documentation](https://github.com/Carthage/Carthage/blob/master/Documentation/Xcode12Workaround.md#workaround).

0 commit comments

Comments
 (0)