Skip to content

kurzdigital/Krampus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Krampus

Version License Platform

Krampus is Santa's little helper and provides authorization for web requests. Currently there exists an authorization implementation for keycloak. Supported are login with an auth code aswell as with username and password. Furthermore Krampus handles refreshing the access token and stores the refresh token safely within the users keychain. Krampus was designed to work seamless with the resource based network lib Santa.

Configure your authorization:

let webservice = ImplWebservice()
lazy var authorization = {
    return Krampus.keycloakAuthorization(
        baseUrl: "https://keycloak-url.de",
        clientId: "client",
        realm: "realm",
        redirectUrl: "needed for login with auth code",
        keychain: CredentialsKeychain(credentialsServiceName: "KeychainTestKrampusLogin"),
        webservice: webservice)
}()

To login with a running keycloak instance:

authorization.login(withUsername: "username", password: "password") { result in
    switch result {
    case .success:
        // The credentials are already saved within the keychain.
        // Show the user that the login was successful
    case .failure(let error):
        // Handle error
    }
}

Enable authorization for Santa Webservice:

let webservice = ImplWebservice()
webservice.authorization = authorization

Features

  • Parse JWT to accessible dictionary

Keycloak

  • Login with Auth Code
  • Login with username and password
  • Logout
  • Handle access token refresh
  • Store Keycloak credentials within the users keychain
  • Support offline tokens

TODO

  • Write more tests
  • Provide usage documentation

Requirements

  • Swift 5
  • iOS 12.0 or newer

Installation

Krampus is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Krampus'

Author

KURZ Digital Solutions GmbH & Co. KG

License

Krampus is available under the MIT license. See the LICENSE file for more info.

About

Keycloak authorization for networking lib Santa

Resources

License

Stars

Watchers

Forks

Packages

No packages published