Configuration model
To establish communication with the Token Server, the iOS SDK has to be provided with a correct configuration model. This can be done using the SDK Configurator. This tool will automatically set all required values and ensure those are aligned with configuration on the token server. The process is explained in our developer quickstart.
In order to configure the SDK, some data needs to be provided:
-
Application data:
ONGAppIdentifier
- Application identifier used in dynamic client registration.ONGAppPlatform
- Application platform used in dynamic client registration.ONGAppVersion
- Application version used in dynamic client registration.ONGAppBaseURL
- Base url of the OAuth Server installation.ONGResourceBaseURL
- Base url of the resource server.ONGRedirectURL
- Redirect url used to complete registration process.
-
Certificates used for the Certificate pinning.
- Server public key when Payload Encryption feature is turned on.
What the SDK configurator does for you
If the SDK Configurator
was used to apply configuration then it automaticlly generates OneginiConfigModel
class with provided data.
An example of the generated file
@implementation OneginiConfigModel
+ (NSArray *)certificates
{
return @[@"MIIGEz...zlIPK1aEn8="]; __Base64Certificates
}
+ (NSDictionary *)configuration
{
return @{
@"ONGAppIdentifier" : @"ExampleApp",
@"ONGAppPlatform" : @"ios",
@"ONGAppVersion" : @"5.0.0",
@"ONGAppBaseURL" : @"https:__demo-msp.onegini.com",
@"ONGResourceBaseURL" : @"https:__demo-msp.onegini.com_resources",
@"ONGRedirectURL" : @"oneginiexample:__loginsuccess",
};
}
+ (NSString *)serverPublicKey
{
return @"355C555820D47CB2010F601D96CB134A3026BFEC7F23732E0890CD5E62AB2D24";
}
@end
__ Swift version of ConfigModel not yet availiable.
Manual configuration
To configure the SDK manually its required to create an instance of ConfigModel
. Then this object needs to be passed to ClientBuilder
when creating Client
instance. Example:
let model = ConfigModel(dictionary: ["ONGAppIdentifier": "ONGAppIdentifier",
"ONGAppPlatform": "ONGAppPlatform",
"ONGAppVersion": "1.0.0",
"ONGAppBaseURL": "https:__...",
"ONGResourceBaseURL": "https:__..._",
"ONGRedirectURL": "...:__loginsuccess"])!
let publicKey = "XXX" __publicKey can be retrived from JSON exported in config zip from TS
let certs = ["XXX"]
ClientBuilder().setConfigModel(model)
.setX509PEMCertificates(certs)
.setServerPublicKey(publicKey)
.build()
ONGConfigModel *configModel = [[ONGConfigModel alloc] initWithDictionary:@{
ONGAppIdentifier : @"appIdentifier"
ONGAppPlatform : @"ios"
ONGAppVersion : @"1.0.0"
ONGAppBaseURL : @"https:__token-server.com"
ONGResourceBaseURL : @"https:__resource-server.com"
ONGRedirectURL : @"appscheme:__loginsuccess"
}];
ONGClientBuilder *clientBuilder = [[ONGClientBuilder alloc] init];
self.oneginiClient = [[[clientBuilder setConfigModel:configModel] setX509PEMCertificates:@[certificate]] build];
ConfigModel
can also be instantiated from a .plist file using filePath
initializer:
let configModel = ConfigModel(filePath: configurationFilePath)
let oneginiClient = ClientBuilder.setConfigModel(configModel)
.setX509PEMCertificates([certificate])
.build()
ONGConfigModel *configModel = [[ONGConfigModel alloc] initWithContentsOfFile:configurationFilePath];
ONGClientBuilder *clientBuilder = [[ONGClientBuilder alloc] init];
self.oneginiClient = [[[clientBuilder setConfigModel:configModel] setX509PEMCertificates:@[certificate]] build];