javascript - Complete OpenIDConnect auth when requesting via Ajax -


the normal openidconnect server works like:

  • you go a.com/secure-resource
  • you 302 server
  • your browser handles , sends identity server
  • you login there
  • it sends a.com via post
  • you logged in on a.com , a.com/secure-resource on 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 domain a.com)
  • b.com configured use openidconnect.
  • but because request b.com via ajax, user cannot redirected idserver. (all in response 302)

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

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -