Class OpenIDProvider
Provides OpenID Provider (OP) support for OpenID Connect (OIDC) authentication.
Inheritance
Implements
Inherited Members
Namespace: ComponentSpace.OpenID
Assembly: ComponentSpace.OpenID.dll
Syntax
public class OpenIDProvider : IOpenIDProvider
Constructors
OpenIDProvider(IServiceProvider, IConfigurationResolver, ICertificateLoader, ISessionStore, IAccessTokenCache, ILoggerFactory)
Initializes a new instance of the OpenIDProvider
class.
Declaration
public OpenIDProvider(IServiceProvider serviceProvider, IConfigurationResolver configurationResolver, ICertificateLoader certificateLoader, ISessionStore sessionStore, IAccessTokenCache accessTokenCache, ILoggerFactory loggerFactory)
Parameters
Type | Name | Description |
---|---|---|
IServiceProvider | serviceProvider | The service provider. |
IConfigurationResolver | configurationResolver | The configuration resolver. |
ICertificateLoader | certificateLoader | The certificate loader. |
ISessionStore | sessionStore | The session store. |
IAccessTokenCache | accessTokenCache | The access token cache. |
Microsoft.Extensions.Logging.ILoggerFactory | loggerFactory | The logger factory. |
Properties
ConfigurationName
Gets or sets the OpenID configuration name.
For most applications, a single OpenID configuration is used and the OpenID configuration name is not required. For multi-tenanted applications and other special use cases with multiple OpenID configurations, the name specifies the configuration to use.
Declaration
public virtual string ConfigurationName { get; set; }
Property Value
Type | Description |
---|---|
System.String | The configuration name. |
Methods
ClearSessionAsync(String)
Clears the current session state for the specified client or all clients.
Declaration
public virtual async Task ClearSessionAsync(string clientID = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | clientID | The client ID. |
Returns
Type | Description |
---|---|
Task | A task that represents the operation. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |
CreateJwtAccessTokenAsync(String, String, String, String, Nullable<IList<Claim>>, Nullable<DateTime>)
Creates a JWT access token.
Declaration
public virtual async Task<string> CreateJwtAccessTokenAsync(string clientID, string audience, string subject = null, string scope = null, IList<Claim>? claims = null, DateTime? utcJwtExpiresAt = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | clientID | The client ID. |
System.String | audience | The audience. |
System.String | subject | The subject. |
System.String | scope | The scope. |
System.Nullable<IList<System.Security.Claims.Claim>> | claims | The claims. |
System.Nullable<DateTime> | utcJwtExpiresAt | The UTC date/time when the JWT expires. |
Returns
Type | Description |
---|---|
Task<System.String> | A task that represents the operation and returns the JWT access token. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |
GetKeysAsync()
Gets the OpenID provider's keys.
Declaration
public virtual async Task<IActionResult> GetKeysAsync()
Returns
Type | Description |
---|---|
Task<Microsoft.AspNetCore.Mvc.IActionResult> | A task that represents the operation and returns the action result. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |
GetMetadataAsync()
Gets the OpenID provider's metadata.
Declaration
public virtual async Task<IActionResult> GetMetadataAsync()
Returns
Type | Description |
---|---|
Task<Microsoft.AspNetCore.Mvc.IActionResult> | A task that represents the operation and returns the action result. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |
GetStatusAsync()
Gets the current OpenID session status.
Declaration
public virtual async Task<IDictionary<string, IOpenIDStatus>> GetStatusAsync()
Returns
Type | Description |
---|---|
Task<IDictionary<System.String, IOpenIDStatus>> | A task that represents the operation and returns the OpenID session status. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |
GetTokensAsync(GetRefreshTokenResultAsync, GetClientCredentialsResultAsync, GetUserCredentialsResultAsync)
Gets the tokens as part of the authorization code flow.
Declaration
public virtual async Task<IActionResult> GetTokensAsync(GetRefreshTokenResultAsync getRefreshTokenResult = null, GetClientCredentialsResultAsync getClientCredentialsResult = null, GetUserCredentialsResultAsync getUserCredentialsResult = null)
Parameters
Type | Name | Description |
---|---|---|
GetRefreshTokenResultAsync | getRefreshTokenResult | The delegate that returns the refresh token result. |
GetClientCredentialsResultAsync | getClientCredentialsResult | The delegate that returns the client credentials result. |
GetUserCredentialsResultAsync | getUserCredentialsResult | The delegate that returns the user credentials result. |
Returns
Type | Description |
---|---|
Task<Microsoft.AspNetCore.Mvc.IActionResult> | A task that represents the operation and returns the action result. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |
GetUserInfoAsync()
Gets the user information.
Declaration
public virtual async Task<IActionResult> GetUserInfoAsync()
Returns
Type | Description |
---|---|
Task<Microsoft.AspNetCore.Mvc.IActionResult> | A task that represents the operation and returns the action result. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |
IntrospectTokenAsync()
Introspects the token.
Declaration
public virtual async Task<IActionResult> IntrospectTokenAsync()
Returns
Type | Description |
---|---|
Task<Microsoft.AspNetCore.Mvc.IActionResult> | A task that represents the operation and returns the action result. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |
ReceiveAuthnRequestAsync()
Receives the authentication request.
Declaration
public virtual async Task<AuthenticationRequest> ReceiveAuthnRequestAsync()
Returns
Type | Description |
---|---|
Task<AuthenticationRequest> | A task that represents the operation and returns the authentication request. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |
ReceiveLogoutRequestAsync()
Receives the logout request.
Declaration
public virtual async Task<LogoutRequest> ReceiveLogoutRequestAsync()
Returns
Type | Description |
---|---|
Task<LogoutRequest> | A task that represents the operation and returns the logout request. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |
RevokeAccessTokenAsync(String)
Revokes the access token.
Declaration
public virtual async Task RevokeAccessTokenAsync(string accessToken)
Parameters
Type | Name | Description |
---|---|---|
System.String | accessToken | The access token. |
Returns
Type | Description |
---|---|
Task | A task that represents the operation. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |
SendAuthnErrorResponseAsync(String, String, String, String)
Sends the authentication error response.
Declaration
public virtual async Task<IActionResult> SendAuthnErrorResponseAsync(string errorCode, string errorDescription = null, string errorUri = null, string correlationID = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | errorCode | The error code. |
System.String | errorDescription | The error description. |
System.String | errorUri | The error page URI. |
System.String | correlationID | The correlation ID identifying the authentication request to respond to. |
Returns
Type | Description |
---|---|
Task<Microsoft.AspNetCore.Mvc.IActionResult> | A task that represents the operation and returns the action result. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |
SendAuthnResponseAsync(String, Nullable<IEnumerable<Claim>>, String, String, Nullable<DateTime>, String)
Sends the authentication response.
Declaration
public virtual async Task<IActionResult> SendAuthnResponseAsync(string subject, IEnumerable<Claim>? claims = null, string accessToken = null, string refreshToken = null, DateTime? utcAccessTokenExpiresAt = null, string correlationID = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | subject | The subject identifier to include in the ID token. |
System.Nullable<IEnumerable<System.Security.Claims.Claim>> | claims | The claims to include in the ID token. |
System.String | accessToken | The access token. |
System.String | refreshToken | The refresh token. |
System.Nullable<DateTime> | utcAccessTokenExpiresAt | The UTC date/time when the access token expires. |
System.String | correlationID | The correlation ID identifying the authentication request to respond to. |
Returns
Type | Description |
---|---|
Task<Microsoft.AspNetCore.Mvc.IActionResult> | A task that represents the operation and returns the action result. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |
SendLogoutResponseAsync(String)
Sends the logout response.
Declaration
public virtual async Task<IActionResult> SendLogoutResponseAsync(string correlationID = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | correlationID | The correlation ID identifying the logout request to respond to. |
Returns
Type | Description |
---|---|
Task<Microsoft.AspNetCore.Mvc.IActionResult> | A task that represents the operation and returns the action result. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |
ToErrorCode(Exception)
Converts the exception to an error code.
Declaration
public virtual string ToErrorCode(Exception exception)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | The exception. |
Returns
Type | Description |
---|---|
System.String | The error code. |
Exceptions
Type | Condition |
---|---|
OpenIDException | Thrown when the operation fails. |