Skip to content

Repository files navigation

IdentityModel

A .NET standard helper library for claims-based identity, OAuth 2.0 and OpenID Connect.

DiscoveryClient

Client library to retrieve OpenID Connect discovery documents and key sets.

vardiscoveryClient=newDiscoveryClient("https://demo.identityserver.io");vardoc=awaitdiscoveryClient.GetAsync();vartokenEndpoint=doc.TokenEndpoint;varkeys=doc.KeySet.Keys;

TokenClient

Client library for OAuth 2.0 and OpenID Connect token endpoints.

Features:

  • Support for client credentials & resource owner password credential flow
  • Support for exchanging authorization codes with tokens
  • Support for refreshing tokens
  • Support for extensions grants and assertions
  • Support for client secrets via Basic Authentication, POST body and X.509 client certificates
  • Extensible for custom parameters
  • Parsing of token response messages

Example:

varclient=newTokenClient(doc.TokenEndpoint,"client_id","secret");varresponse=awaitclient.RequestClientCredentialsAsync("scope");vartoken=response.AccessToken;

UserInfoClient

Client library for the OpenID Connect user info endpoint

varuserInfoClient=newUserInfoClient(doc.UserInfoEndpoint);varresponse=awaituserInfoClient.GetAsync(token);varclaims=response.Claims;

IntrospectionClient

Client library for the OAuth 2 introspection endpoint

varintrospectionClient=newIntrospectionClient(doc.IntrospectionEndpoint,"scope_name","scope_secret");varresponse=awaitintrospectionClient.SendAsync(newIntrospectionRequest{Token=token});varisActive=response.IsActive;varclaims=response.Claims;

RequestUrl

Helper class for creating request URLs (e.g. for authorize and end_session).

varrequest=newRequestUrl(doc.AuthorizationEndpoint);varurl=request.CreateAuthorizeUrl(clientId:"client",responseType:OidcConstants.ResponseTypes.CodeIdToken,responseMode:OidcConstants.ResponseModes.FormPost,redirectUri:"https://myapp.com/callback",state:CryptoRandom.CreateUniqueId(),nonce:CryptoRandom.CreateUniqueId());

AuthorizeResponse

Helper class for parsing OpenID Connect/OAuth 2 authorize responses

varresponse=newAuthorizeResponse(url);varaccessToken=response.AccessToken;varidToken=response.IdentityToken;varstate=response.State;

Fluent API to access the X.509 Certificate store

e.g. do
var cert = X509.LocalMachine.My.SubjectDistinguishedName.Find("CN=sts").First();

Base64 URL encoder/decoder

Helper for working with URL safe base64 encodings

Epoch Time Extensions

Helper for converting DateTime and DateTimeOffset to/from Epoch Time

Time Constant Comparer

Helper for comparing strings without leaking timing information

JWT/OpenID Connect Claim Types

Constants for standard claim types used in JWT, OAuth 2.0 and OpenID Connect

OpenID Connect Constants

Constants for the OpenID Connect/OAuth 2 protocol

About

.NET standard helper library for claims-based identity, OAuth 2.0 and OpenID Connect.

Resources

Stars

0 stars

Watchers

8 watching

Forks

Releases

Packages

Contributors

Languages