Client > JWT Token -> REST Service -> SOAP Service
1. User call the REST Web Service (Web API Service)
2. Web API service redirect the client to STS (Token Manager), after presenting the correct credentials. User Get the JWT token.
3. Now Web API makes the call to WCF SOAP Service and presents the token.
4. Web API and WCF SOAP service can be on different machine.
5. User wants to send the received claims via Web API to SOAP service.
6. We want WCF SOAP service to validate the JWT token and authorize as well.
Like validity of token and claims associated.
Run following command to install the package with VS:
PM> Install-Package System.IdentityModel.Tokens.Jwt
All my client does is create a hard coded JWT token via code and send it to server.
WCF service is implemented with a “IDispatchMessageInspector” which will provide me access to “AfterReceiveRequest” method to parse the incoming token.
Finally we can see and set the received claims:
var tokenHandler = new JwtSecurityTokenHandler();
var claimsPrincipal = tokenHandler.ValidateToken(myEncryptedToken, tokenValidationParameters, out validatedToken);
// Parse the Security Token and set the claims.
Service1.CustomClaimsIdentity = Thread.CurrentPrincipal.Identity as ClaimsIdentity;
Please get the complete sample:
Hope this help!