I am currently generating SAML tokens from ADFS as follows:
WSTrustChannelFactory factory = null; try { // use a UserName Trust Binding for username authentication factory = new WSTrustChannelFactory( new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential), new EndpointAddress("https://adfs.company.com/adfs/services/trust/13/usernamemixed")); factory.TrustVersion = TrustVersion.WSTrust13; factory.Credentials.UserName.UserName = "user"; factory.Credentials.UserName.Password = "pw"; var rst = new RequestSecurityToken { RequestType = RequestTypes.Issue, AppliesTo = new EndpointReference(relyingPartyId), KeyType = KeyTypes.Bearer }; IWSTrustChannelContract channel = factory.CreateChannel(); GenericXmlSecurityToken genericToken = channel.Issue(rst) as GenericXmlSecurityToken; } finally { if (factory != null) { try { factory.Close(); } catch (CommunicationObjectFaultedException) { factory.Abort(); } } }
Now let's say that I am creating a web application that uses these tokens for authentication. As far as I know, the workflow should be like this:
- Create token
- the client receives the generated token (after a valid login)
- client cache token
- client uses token for next login
- web application checks token, no need to call ADFS
How can I confirm that the token that the client represents is valid? Do I need an ADFS server certificate to decrypt a token?
c # validation adfs saml
hoetz
source share