wif - Using Microsoft Jwt handler with symmetric signing key using Oauth 2 resource owner flow -
i'm trying use oauth 2 resource owner flow authorize mobile client against web api services. i'm using thinktecture identityserver issue jwt token symmetric signing key.
on client side i'm using thinktecture identitymodel setup token validation. webapiconfig looks this:
var jwtsecuritytokenhandler = new jwtsecuritytokenhandler(); var mapping = new authenticationoptionmapping { // credentials options = authenticationoptions.forauthorizationheader("bearer"), // how validate them tokenhandler = new securitytokenhandlercollection { jwtsecuritytokenhandler }, // hint give if not successful scheme = authenticationscheme.schemeonly("bearer") }; var authconfig = new authenticationconfiguration(){requiressl = false}; authconfig.addmapping(mapping); config.messagehandlers.add(new authenticationhandler(authconfig)); in identitymodel.config have following:
<system.identitymodel> <identityconfiguration> <claimsauthorizationmanager type="presentationhost.claims.mobileclaimsauthorizationmanager, presentationhost"/> <audienceuris> <add value="http://localhost:22674/" /> </audienceuris> <securitytokenhandlers> <add type="system.identitymodel.tokens.jwtsecuritytokenhandler, system.identitymodel.tokens.jwt" /> </securitytokenhandlers> <issuernameregistry type="system.identitymodel.tokens.validatingissuernameregistry, system.identitymodel.tokens.validatingissuernameregistry"> <authority name="http://identityserver.v2.thinktecture.com/trust/auth"> <keys> <add symmetrickey="tvnrmpwebgz3xewvsxrswlie3drxj3aawgnxzkc1od0"/> </keys> <validissuers> <add name="http://identityserver.v2.thinktecture.com/trust/auth" /> </validissuers> </authority> </issuernameregistry> <issuertokenresolver type="system.identitymodel.tokens.namedkeyissuertokenresolver, system.identitymodel.tokens.jwt"/> <securitykey symmetrickey="tvnrmpwebgz3xewvsxrswlie3drxj3aawgnxzkc1od0" name="http://identityserver.v2.thinktecture.com/trust/auth" /> <!--certificationvalidationmode set "none" the identity , access tool visual studio. development purposes.--> <certificatevalidation certificatevalidationmode="none" />
taken link on http://leastprivilege.com/2013/07/16/identityserver-using-ws-federation-with-jwt-tokens-and-symmetric-signatures/ found via stack overflow post: how configure microsoft jwt symmetric key?
i attempted use derived class found in post, when attempted run line:
var resolver = (namedkeyissuertokenresolver)this.configuration.issuertokenresolver; i invalidcastexception because issuertokenresolver of type x509certificatestoreresolver , not of type namedkeyissuertokenresolver.
it appears i'm still missing configuration or code correct tokenresolver configured. have thoughts?
Comments
Post a Comment