javascript - Complete OpenIDConnect auth when requesting via Ajax -
the normal openidconnect server works like:
- you go
a.com/secure-resource - you
302server - your browser handles , sends identity server
- you login there
- it sends
a.comviapost - you logged in on
a.com,a.com/secure-resourceon browser.
however have scenario i'm trying solve need help.
- the user logged in on idserver
- the user logged in on
a.com - the user not logged in on
b.com - we need send ajax call web server
b.com(from domaina.com) b.comconfigured use openidconnect.- but because request
b.comvia ajax, user cannot redirected idserver. (all in response302)
we can go ahead , handle 302 via ajax (i'm still not sure whether work, security-wise).
but
is there scenario in identityserver/openidconnect designed these situations?
with identityserver in scenario setup server b.com use bearer token authentication, need use access token provided a.com in headers of ajax call
$.ajax({ url: 'http://b.com', headers: { authorization: "bearer " + access token } }) the javascript identityserver client samples have ways of retrieving token identity server, see here
in controller can user , token this
// claims values var token= (user claimsprincipal).claims .where(c => c.type == "access_token") .select(c => c.value).singleordefault(); in other parts of application can use this
//get current claims principal var identity = (claimsprincipal)thread.currentprincipal; // claims values var token = identity.claims.where(c => c.type == "accept_token") .select(c => c.value).singleordefault();
Comments
Post a Comment