angularjs - How to use SAML authentication in a mobile application? -
i'm trying understand how saml authentication flow work in mobile environment client (angularjs based), api server (node & passport based), , idp exist on different domains.
from i've gathered general practice have server return 401 client if there's no authentication present (i.e. client didn't include bearer token in request). client understands 401 response indicates open login endpoint on server. when login endpoint opened makes passport call auth provider (which redirects user auth provider's site) , supplies callback url. when user authenticates, auth provider redirects provided callback url, allows server retrieve information auth provider's response , construct token of sort (e.g. jwt) can used client (i.e. included in headers) when making rest calls identify itself.
my question is: how client token server? because we're in redirect-based authentication flow, can't return token
callback function; display token in browser without handing off of client. server issue 302 redirect pointing client domain , include authentication token in header? maybe should not redirect client server in first place , instead window.open()
, use window.opener.postmessage
or old fashioned/mobile-unfriendly?
this question talks authentication against saml idp, i'm interested in getting more details last bullet point , how work angularjs-based client.
many examples i've seen online either single domain using oauth/saml (passport-saml-example), avoids issue of having client exist on separate domain, or use 2 domains basic authentication, avoids issue of redirecting third party authentication, i'm having trouble finding examples uses bits , pieces i'm trying work with.
this blog post seems close i'm trying accomplish (see googlesignincallback) , uses 302 redirect imagined solution relies on explicitly knowing client url redirect to, seems problematic if wanted support multiple client types (i.e. native applications) in future.
eventually able work solution having application open browser window (cordova's inappbrowser) saml-enabled application, have application complete normal saml flow, , saml-enabled application generated jwt. mobile application able extract jwt string browser window inappbrowser's executescript functionality. pass jwt string along api server, able validate jwt signed , trusted.
after implemented solution saw there similar functionality available on github:
https://github.com/feedhenry-templates/saml-service
https://github.com/feedhenry-templates/saml-cloud-app
https://github.com/feedhenry-templates/saml-cordova-app
hopefully helps else trying deal issue!
Comments
Post a Comment