Class AbstractOidcProvider
Implementation of the Abstract OpenID Connect Provider
Inheritance
Implements
Namespace: i5.Toolkit.Core.OpenIDConnectClient
Assembly: cs.temp.dll.dll
Syntax
public abstract class AbstractOidcProvider : IOidcProvider
Constructors
AbstractOidcProvider()
Creates a new instance of the client
Declaration
protected AbstractOidcProvider()
Fields
authorizationEndpoint
The endpoint for the log in
Declaration
protected string authorizationEndpoint
Field Value
Type | Description |
---|---|
string |
serverName
The OIDC server url - Used for accessing the endpoints published at its well-known URL
Declaration
protected string serverName
Field Value
Type | Description |
---|---|
string |
tokenEndpoint
The end point where the access token can be requested
Declaration
protected string tokenEndpoint
Field Value
Type | Description |
---|---|
string |
userInfoEndpoint
The end point where user information can be requested
Declaration
protected string userInfoEndpoint
Field Value
Type | Description |
---|---|
string |
Properties
AuthorizationFlow
Gets or sets the used authorization flow
Declaration
public AuthorizationFlow AuthorizationFlow { get; set; }
Property Value
Type | Description |
---|---|
AuthorizationFlow |
Browser
The implementation that should accesss the browser
Declaration
public IBrowser Browser { get; set; }
Property Value
Type | Description |
---|---|
IBrowser |
ClientData
Client data that are required to authorize the client at the provider
Declaration
public ClientData ClientData { get; set; }
Property Value
Type | Description |
---|---|
ClientData |
JsonSerializer
Serializer that is responsible for parsing JSON data and converting to JSON
Declaration
public IJsonSerializer JsonSerializer { get; set; }
Property Value
Type | Description |
---|---|
IJsonSerializer |
RestConnector
Specifies how the REST API of the Web service is accessed
Declaration
public IRestConnector RestConnector { get; set; }
Property Value
Type | Description |
---|---|
IRestConnector |
Methods
CheckAccessTokenAsync(string)
Checks if the access token is valid by checking it at the provider
Declaration
public virtual Task<bool> CheckAccessTokenAsync(string accessToken)
Parameters
Type | Name | Description |
---|---|---|
string | accessToken | The access token that should be checked |
Returns
Type | Description |
---|---|
Task<><bool> | True if the access token is valid, otherwise false |
CheckEndpoints(bool)
Declaration
protected virtual bool CheckEndpoints(bool printError = true)
Parameters
Type | Name | Description |
---|---|---|
bool | printError |
Returns
Type | Description |
---|---|
bool |
DecodeIDToken<T>(string)
Decodes a JWT using Base64 to get user info
Declaration
public virtual T DecodeIDToken<T>(string idtoken) where T : AbstractUserInfo
Parameters
Type | Name | Description |
---|---|---|
string | idtoken | The id token returned in the AuthorizationFlowAnswer |
Returns
Type | Description |
---|---|
T | The user info from the id token |
Type Parameters
Name | Description |
---|---|
T |
GetAccessToken(Dictionary<string, string>)
Gets the access token from a list of parameters in a Web answer
Declaration
public virtual string GetAccessToken(Dictionary<string, string> redirectParameters)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<TKey, TValue><string, string> | redirectParameters | The parameters of the Web answer as a dictionary |
Returns
Type | Description |
---|---|
string | Returns the access token if it exists in the parameters, otherwise an empty string is returned |
GetAccessTokenFromCodeAsync(string, string)
Gets the access token based on a previously retrieved authorization code
Declaration
public virtual Task<string> GetAccessTokenFromCodeAsync(string code, string redirectUri)
Parameters
Type | Name | Description |
---|---|---|
string | code | The authorization code |
string | redirectUri | The redirect URI which was used during the login |
Returns
Type | Description |
---|---|
Task<><string> | Returns the access token if it could be retrieved; otherwise it returns an empty string |
GetAuthorizationCode(Dictionary<string, string>)
Extracts the authorization code from parameters of a Web answer
Declaration
public virtual string GetAuthorizationCode(Dictionary<string, string> redirectParameters)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<TKey, TValue><string, string> | redirectParameters | Parameters of a Web answer as a dictionary |
Returns
Type | Description |
---|---|
string | The authorization code if it could be found, otherwise an empty string is returned |
GetUserInfo<T>(string)
Gets information about the logged in user from the idtoken
Declaration
public virtual IUserInfo GetUserInfo<T>(string idToken) where T : AbstractUserInfo
Parameters
Type | Name | Description |
---|---|---|
string | idToken | The id token to received from authentication |
Returns
Type | Description |
---|---|
IUserInfo | Returns information about the logged in user |
Type Parameters
Name | Description |
---|---|
T |
GetUserInfoAsync(string)
Gets information about the logged in user from the provider
Declaration
public virtual Task<IUserInfo> GetUserInfoAsync(string accessToken)
Parameters
Type | Name | Description |
---|---|---|
string | accessToken | The access token to authenticate the user |
Returns
Type | Description |
---|---|
Task<><IUserInfo> | Returns information about the logged in user if the request was successful, otherwise null |
InitializeEndpointsAsync()
Sets the required endpoints
Declaration
public virtual Task<EndpointsData> InitializeEndpointsAsync()
Returns
Type | Description |
---|---|
Task<><EndpointsData> |
OpenLoginPage(string[], string)
Opens the login page in the system's default Web browser
Declaration
public virtual void OpenLoginPage(string[] scopes, string redirectUri)
Parameters
Type | Name | Description |
---|---|---|
string[] | scopes | The OpenID Connect scopes that the user must agree to |
string | redirectUri | The URI to which the browser should redirect after the successful login |
ParametersContainError(Dictionary<string, string>, out string)
Checks if the provider included error messages in the parameters of a Web answer
Declaration
public virtual bool ParametersContainError(Dictionary<string, string> parameters, out string errorMessage)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<TKey, TValue><string, string> | parameters | The parameters of a Web answer as a dictionary |
string | errorMessage | The error message that the provider included, empty if no error exists |
Returns
Type | Description |
---|---|
bool | Returns true if the parameters contain an error message, otherwise false |
RequestEndpointsDataAsync()
Extracts the required endpoints from the well-known definition of the server
Declaration
protected Task<EndpointsData> RequestEndpointsDataAsync()
Returns
Type | Description |
---|---|
Task<><EndpointsData> |
ServerName()
Declaration
public string ServerName()
Returns
Type | Description |
---|---|
string |