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 async Task<bool> CheckAccessTokenAsync(string accessToken)
Parameters
Type | Name | Description |
---|---|---|
String | accessToken | The access token that should be checked |
Returns
Type | Description |
---|---|
Task<Boolean> | True if the access token is valid, otherwise false |
CheckEndpoints(Boolean)
Declaration
protected virtual bool CheckEndpoints(bool printError = true)
Parameters
Type | Name | Description |
---|---|---|
Boolean | printError |
Returns
Type | Description |
---|---|
Boolean |
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 |
---|---|---|
Dictionary<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 async 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 |
---|---|---|
Dictionary<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 async 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 async 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 |
---|---|---|
Dictionary<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 |
---|---|
Boolean | 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 async Task<EndpointsData> RequestEndpointsDataAsync()
Returns
Type | Description |
---|---|
Task<EndpointsData> |
ServerName()
Declaration
public string ServerName()
Returns
Type | Description |
---|---|
String |