Skip to content

Commit

Permalink
Merge pull request #157 from SLab7/master
Browse files Browse the repository at this point in the history
add settings for keychain accounts
  • Loading branch information
p2 authored Nov 19, 2016
2 parents aa25d75 + 99efb88 commit 7c9d69f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Sources/Base/OAuth2Base.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ open class OAuth2Base: OAuth2Securable {
get { return clientConfig.accessToken }
set { clientConfig.accessToken = newValue }
}
/// The receiver's id token.
open var idToken: String? {
get { return clientConfig.idToken }
Expand Down Expand Up @@ -168,10 +168,11 @@ open class OAuth2Base: OAuth2Securable {
- client_name (string)
- registration_uri (URL-string)
- logo_uri (URL-string)

- keychain (bool, true by default, applies to using the system keychain)
- keychain_access_mode (string, value for keychain kSecAttrAccessible attribute, kSecAttrAccessibleWhenUnlocked by default)
- keychain_access_group (string, value for keychain kSecAttrAccessGroup attribute, nil by default)
- keychain_account_for_client_credentials(string, "clientCredentials" by default)
- keychain_account_for_tokens(string, "currentTokens" by default)
- verbose (bool, false by default, applies to client logging)
- secret_in_body (bool, false by default, forces the flow to use the request body for the client secret)
- token_assume_unexpired (bool, true by default, whether to use access tokens that do not come with an "expires_in" parameter)
Expand Down
10 changes: 8 additions & 2 deletions Sources/Base/OAuth2Securable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,18 @@ open class OAuth2Securable: OAuth2Requestable {
/**
Base initializer.

Looks at the `verbose`, `keychain`, `keychain_access_mode` and `keychain_access_group`. Everything else is handled by subclasses.
Looks at the `verbose`, `keychain`, `keychain_access_mode`, `keychain_access_group` `keychain_account_for_client_credentials` and `keychain_account_for_tokens`. Everything else is handled by subclasses.
*/
public init(settings: OAuth2JSON) {
self.settings = settings

// keychain settings
if let accountForClientCredentials = settings["keychain_account_for_client_credentials"] as? String {
keychainAccountForClientCredentials = accountForClientCredentials
}
if let accountForTokens = settings["keychain_account_for_tokens"] as? String {
keychainAccountForTokens = accountForTokens
}
if let keychain = settings["keychain"] as? Bool {
useKeychain = keychain
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/Flows/OAuth2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ open class OAuth2: OAuth2Base {
- keychain (bool, true by default, applies to using the system keychain)
- keychain_access_mode (string, value for keychain kSecAttrAccessible attribute, kSecAttrAccessibleWhenUnlocked by default)
- keychain_access_group (string, value for keychain kSecAttrAccessGroup attribute, nil by default)
- keychain_account_for_client_credentials(string, "clientCredentials" by default)
- keychain_account_for_tokens(string, "currentTokens" by default)
- verbose (bool, false by default, applies to client logging)
- secret_in_body (bool, false by default, forces the flow to use the request body for the client secret)
- token_assume_unexpired (bool, true by default, whether to use access tokens that do not come with an "expires_in" parameter)
Expand Down

0 comments on commit 7c9d69f

Please sign in to comment.