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
- Parse JWT to accessible dictionary
- Login with Auth Code
- Login with username and password
- Logout
- Handle access token refresh
- Store Keycloak credentials within the users keychain
- Support offline tokens
- Write more tests
- Provide usage documentation
- Swift 5
- iOS 12.0 or newer
Krampus is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Krampus'
KURZ Digital Solutions GmbH & Co. KG
Krampus is available under the MIT license. See the LICENSE file for more info.