OAuth2Securable

open class OAuth2Securable : OAuth2Requestable

Base class to add keychain storage functionality.

  • Server-side settings, as set upon initialization.

    Declaration

    Swift

    final let settings: OAuth2JSON
  • If set to true (the default) will use system keychain to store tokens. Use "keychain": bool in settings.

    Declaration

    Swift

    public var useKeychain: Bool { get set }
  • The keychain account to use to store tokens. Defaults to “currentTokens”.

    Declaration

    Swift

    open var keychainAccountForTokens: String { get set }
  • The keychain account name to use to store client credentials. Defaults to “clientCredentials”.

    Declaration

    Swift

    open var keychainAccountForClientCredentials: String { get set }
  • Defaults to kSecAttrAccessibleWhenUnlocked. MUST be set via keychain_access_group init setting.

    Declaration

    Swift

    open internal(set) var keychainAccessMode: CFString { get }
  • Keychain access group, none is set by default. MUST be set via keychain_access_group init setting.

    Declaration

    Swift

    open internal(set) var keychainAccessGroup: String? { get }
  • Base initializer.

    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.

    Declaration

    Swift

    public init(settings: OAuth2JSON)

Keychain Integration

  • The service key under which to store keychain items. Returns “http://localhost”, subclasses override to return the authorize URL.

    Declaration

    Swift

    open func keychainServiceName() -> String
  • Updates instance properties according to the items found in the given dictionary, which was found in the keychain.

    Declaration

    Swift

    func updateFromKeychainItems(_ items: [String : Any])
  • Items that should be stored when storing client credentials.

    Declaration

    Swift

    open func storableCredentialItems() -> [String : Any]?

    Return Value

    A dictionary with String keys and Any items

  • Stores our client credentials in the keychain.

    Declaration

    Swift

    open func storeClientToKeychain()
  • Items that should be stored when tokens are stored to the keychain.

    Declaration

    Swift

    open func storableTokenItems() -> [String : Any]?

    Return Value

    A dictionary with String keys and Any items

  • Stores our current token(s) in the keychain.

    Declaration

    Swift

    public func storeTokensToKeychain()
  • Unsets the client credentials and deletes them from the keychain.

    Declaration

    Swift

    open func forgetClient()
  • Unsets the tokens and deletes them from the keychain.

    Declaration

    Swift

    open func forgetTokens()