security - How to setup Identity Server 3 for IOS client using Authorization Code flow -
lately i've bee playing around thinktecture's identity server 3 , more clients , flows. want see how communication happens between native ios application , identity server 3 using authorization code flow.
what i've done far consuming sts(identity server 3) asp.net mvc client(hybrid flow) , angularjs client(implicit flow). sts side looks this:
implicit flow client setup on sts:
new client { clientid = "implicitangularclient", clientname = "angular client (implicit)", flow = flows.implicit, allowaccesstoallscopes = true, identitytokenlifetime = 10, accesstokenlifetime = 120, // if want have sso between angular app , mvc app need have option set // false both flows implement(hybrid , implicit). requireconsent = false, // redirect = uri of angular application redirecturis = new list<string> { "https://localhost:44555/callback.html", // silent refresh "https://localhost:44555/silentrefreshframe.html" }, postlogoutredirecturis = new list<string>() { "https://localhost:44555/index.html" } }
hybrid flow client setup on sts:
new client { clientid = "hybridclient", clientname = "mvc client (hybrid)", flow = flows.hybrid, allowaccesstoallscopes = true, // if want have sso between angular app , mvc app need have option set // false both flows implement(hybrid , implicit). requireconsent = false, identitytokenlifetime = 10, accesstokenlifetime = 120, // redirect = uri of mvc application redirecturis = new list<string> { "https://localhost:44556" }, // needed when requesting refresh tokens clientsecrets = new list<secret>() { new secret("hybridflowsecret".sha256()) }, postlogoutredirecturis = new list<string>() { "https://localhost:44556" } }
well, goal setup client native ios application using authorization code flow. have no ios application wish make setup such client if 1 day have ios app, can give client id, client name , client secret have defined , let run. tried find examples on internet didn't have success started digging it. wondering return url should , how processed client-side. following specification: oauth2-native-apps-03, starting section 5. says
there 3 main approaches redirection uris native apps: custom uri schemes, app-claimed https uri schemes, , loopback redirects.
so far, good, far understand, on client side app need register custom uri scheme i've never done before(i've never done ios development in general). more, need open app after specific url(most likely, returnuris url) passed phone browser launched authorization process. spent time on inter app communication ios didn't answer of question is: if want abstract myself ios application , setup , want configure sts, how in terms of setting client object case on sts level? should redirect uri(as far understand kind of reverse dns notation. com.mycompany.apples)? imagine sts administrator , physical client comes me , says: hey, have ios application id, secret , return uri, please set me on sts.
here xamarin project ios client example using following libraries.
- identitymodel.oidcclient 2.0.0
- identitymodel 2.5.1
if going use xamarin viewcontroller.cs has login code connect identityserver.
var options = new oidcclientoptions { authority = "https://demo.identityserver.io", clientid = "native.hybrid", scope = "openid profile email api", redirecturi = "io.identitymodel.native://callback", responsemode = oidcclientoptions.authorizeresponsemode.redirect }; _client = new oidcclient (options); _state = await _client.prepareloginasync (); appdelegate.callbackhandler = handlecallback; safari = new safariservices.sfsafariviewcontroller (new nsurl (_state.starturl)); this.presentviewcontroller (safari, true, null);
if going using single page application spa have sample project uses oidc-client.js library documentation here.
note: have not had luck using url scheme oidc-client.js library. i'm still looking if library supports ability.
if planning on using cordova project here source i've tested with. note: there testing issues may run if don't have ios device test with. ran issue , able test using intel xdx tool, allows push cordova project test server , launch on mobile device via intel app preview application.
- jquery-cordova-oauth2: jquery plugin doing oauth2 login in cordova app. plugin relies on cordova inappbrowser
Comments
Post a Comment