cidaas is a fast and secure Cloud Identity & Access Management solution that standardises what’s important and simplifies what’s complex.
The steps here will guide you through setting up and managing authentication and authorization in your apps using cidaas SDK.
Open the following menu item in Xcode:
File > Add Packages...
In the Search or Enter Package URL search box enter this URL:
https://github.com/Cidaas/cidaas-sdk-ios-v2
Then, select the dependency rule and press Add Package.
Add the following line to your Podfile
:
pod 'Cidaas'
To use only core functionality and to reduce the size of the dependency
pod 'Cidaas/Core'
The following steps are to be followed to use this cidaas SDK.
Create a plist file named Cidaas.plist and fill all the inputs in key value pair. The inputs are mentioned below.
A sample plist file would look like this :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DomainURL</key>
<string>Your Domain URL</string>
<key>RedirectURL</key>
<string>Your redirect url</string>
<key>ClientId</key>
<string>Your client id</string>
<key>CidaasVersion</key>
<string>Your instances major Cidaas Version</string>
</dict>
</plist>
Cidaas V3 has response handling adjustment on some of the cidaas service calls. To migrate to cidaas V3, you need to do the following:
For Example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DomainURL</key>
<string>Your Domain URL</string>
<key>RedirectURL</key>
<string>Your redirect url</string>
<key>ClientId</key>
<string>Your client id</string>
<key>CidaasVersion</key>
<string>3</string>
</dict>
</plist>
The following sections will help you to generate some of the information that is needed for plist.
When you are integrating your own Business App with, you may want to modularize the interactions and attributes. There are like Scope, Roles, Grant-Types, re-direct URLs etc., that you may want to group into one configuration/settings. This can be done by creating App or Client.
The first step to integrate cidaas sdk is the initialization process.
var cidaas = Cidaas();
or use the shared instance
var cidaas = Cidaas.shared
You can login using your native browser and you will be redirected to the App after successful login. To login with your native browser call loginWithBrowser().
var extraParams = Dictionary<String, String>()
extraParams[scopes]="offline_access phone"
cidaas.loginWithBrowser(delegate: self, extraParams: extraParams) {
switch $0 {
case .success(let successResponse):
// your success code here
break
case .failure(let error):
// your failure code here
break
}
}
You can also perform social login using your native browser and you will be redirected to the App after successful login. To perform social login call loginWithSocial().
cidaas.loginWithSocial(provider: "your_social_provider", delegate: self) {
switch $0 {
case .success(let successResponse):
// your success code here
break
case .failure(let error):
// your failure code here
break
}
}
where social provider may be either facebook, google, linkedin or any other providers
Use customScheme or universalLinks to return back the control from browser to App.
Note : Don't forget to add the custom scheme url in your App's redirect url section
Drag and drop an empty view in the storyboard
Change the name of the class in the properties window as CidaasView
Create an IBOutlet for the class and consider this as an object
@IBOutlet var cidaasView: CidaasView!
Inherit the WKNavigationDelegate and call the methods
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
cidaasView.webView(webView, didStartProvisionalNavigation: navigation)
}
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
cidaasView.webView(webView, didFail: navigation, withError: error)
}
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
cidaasView.webView(webView, decidePolicyFor: navigationAction, decisionHandler: decisionHandler)
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
cidaasView.webView(webView, didFinish: navigation)
}
Call the loginWithEmbeddedBrowser() function and get the access token as callback
cidaasView.loginWithEmbeddedBrowser(delegate: self) {
switch $0 {
case .success(let successResponse):
// your success code here
break
case .failure(let error):
// your failure code here
break
}
}