c# - WIF identity delegation to WebAPI REST service -
i have read article: identity delegation ad fs 2.0 step-by-step guide on how perform identity delegation using wif asp.net application end wcf service. have asp.net webapi rest service want able call asp.net application using identity delegation, cannot find information on how accomplish this. mentioned technet article uses createchannelactingas
create channel wcf service using calling user's security token, method not applicable rest api. can point me articles or provide description of how can delegate identity using wif rest service?
my webapi rest service application set , working using wif authentication of this library thinktecture.
i found solution (i using thinktecture identity server). had set delegation account web application uses (webappaccount
) delegate realm service in going identity delegation->add realm in identity server, , in web application had make service call sts providing bootstrap token receive new security token can use authenticate service.
in web app config set:
<system.identitymodel> <identityconfiguration savebootstrapcontext="true">
and in web app code access service looks like:
bootstrapcontext context = claimsprincipal.current.identities.first().bootstrapcontext bootstrapcontext; var factory = new wstrustchannelfactory( new usernamewstrustbinding(securitymode.transportwithmessagecredential), _trusturl); factory.trustversion = trustversion.wstrust13; factory.credentials.username.username = "webappaccount"; factory.credentials.username.password = "p@ssword"; var rst = new requestsecuritytoken { requesttype = requesttypes.issue, keytype = keytypes.bearer, appliesto = new endpointreference(_realm), actas = new securitytokenelement(context.securitytoken) }; var token = factory.createchannel().issue(rst) genericxmlsecuritytoken; var client = new httpclient { baseaddress = _baseaddress }; client.settoken("saml", token.tokenxml.outerxml); var response = client.getasync("api/values").result;
my rest service did not require changes.
Comments
Post a Comment