AuthenticatorClient
Namespace: Meshmakers.Octo.Sdk.ServiceClient.Authentication
Implementation of the client proxy for authentication.
public class AuthenticatorClient : AuthorizationClient, IAuthorizationClient, IAuthenticatorClient, ITokenExchangeClient
Inheritance Object → AuthorizationClient → AuthenticatorClient
Implements IAuthorizationClient, IAuthenticatorClient, ITokenExchangeClient
Constructors
AuthenticatorClient(IOptionsMonitor<AuthenticatorOptions>)
Constructor.
public AuthenticatorClient(IOptionsMonitor<AuthenticatorOptions> options)
Parameters
options IOptionsMonitor<AuthenticatorOptions>
Options for configuration of the client proxy.
Methods
EnsureAuthenticatedAsync(String, String)
public Task<EnsureAuthenticatedData> EnsureAuthenticatedAsync(string refreshToken, string accessToken)
Parameters
refreshToken String
accessToken String
Returns
RequestClientCredentialsTokenAsync(ApiScopes, DefaultScopes, IEnumerable<String>, String, String)
public Task<AuthenticationData> RequestClientCredentialsTokenAsync(ApiScopes apiScopes, DefaultScopes defaultScopes, IEnumerable<string> customScopes, string clientId, string clientSecret)
Parameters
apiScopes ApiScopes
defaultScopes DefaultScopes
customScopes IEnumerable<String>
clientId String
clientSecret String
Returns
RequestClientCredentialsTokenForTenantAsync(String, ApiScopes, DefaultScopes, String, String)
public Task<AuthenticationData> RequestClientCredentialsTokenForTenantAsync(string tenantId, ApiScopes apiScopes, DefaultScopes defaultScopes, string clientId, string clientSecret)
Parameters
tenantId String
apiScopes ApiScopes
defaultScopes DefaultScopes
clientId String
clientSecret String
Returns
BuildClientCredentialsTokenRequest(String, String, String, String, String)
Builds the client-credentials token request. Extracted for unit testing of the
acr_values injection and parameter mapping; the actual HTTP call is the
small wrapper above.
internal static ClientCredentialsTokenRequest BuildClientCredentialsTokenRequest(string tokenEndpoint, string clientId, string clientSecret, string scope, string tenantId)
Parameters
tokenEndpoint String
clientId String
clientSecret String
scope String
tenantId String
Returns
ClientCredentialsTokenRequest
RequestDeviceAuthorizationAsync(ApiScopes, IEnumerable<String>)
public Task<DeviceAuthenticationRequestData> RequestDeviceAuthorizationAsync(ApiScopes apiScopes, IEnumerable<string> customScopes)
Parameters
apiScopes ApiScopes
customScopes IEnumerable<String>
Returns
Task<DeviceAuthenticationRequestData>
RequestDeviceTokenAsync(String)
public Task<DeviceAuthenticationData> RequestDeviceTokenAsync(string deviceCode)
Parameters
deviceCode String
Returns
Task<DeviceAuthenticationData>
RequestPasswordTokenAsync(String, String, ApiScopes, IEnumerable<String>)
public Task<AuthenticationData> RequestPasswordTokenAsync(string username, string password, ApiScopes apiScopes, IEnumerable<string> customScopes)
Parameters
username String
password String
apiScopes ApiScopes
customScopes IEnumerable<String>
Returns
RefreshTokenAsync(String)
public Task<AuthenticationData> RefreshTokenAsync(string refreshToken)
Parameters
refreshToken String
Returns
ExchangeTokenForTenantAsync(String, String, CancellationToken)
public Task<AuthenticationData> ExchangeTokenForTenantAsync(string subjectToken, string targetTenantId, CancellationToken cancellationToken)
Parameters
subjectToken String
targetTenantId String
cancellationToken CancellationToken
Returns
BuildTokenExchangeRequest(String, String, String, String, String)
Builds the RFC 8693 token-exchange request. Extracted for unit testing.
internal static TokenExchangeTokenRequest BuildTokenExchangeRequest(string tokenEndpoint, string clientId, string clientSecret, string subjectToken, string targetTenantId)
Parameters
tokenEndpoint String
clientId String
clientSecret String
subjectToken String
targetTenantId String
Returns
TokenExchangeTokenRequest
MapErrorResponse(String, TokenResponse)
Turns an error response of the token endpoint into the exception the user is shown. A body with an
OAuth error is the identity service's own answer even when the HTTP status is not 400 ( a
tenant database that is down answers 503 temporarily_unavailable with the reason, which used to be
reported as "the identity service could not be reached"). Only a response without such a body, or without a
response at all, means unreachable.
internal static TenantTokenExchangeDeniedException MapErrorResponse(string targetTenantId, TokenResponse response)
Parameters
targetTenantId String
response TokenResponse
Returns
TenantTokenExchangeDeniedException
MapExchangeError(String, String)
Maps an OAuth error of the identity service to the cause the user is told about. The error
descriptions are those of the identity service's tenant exchange; an explicit
tenant_not_provisioned error is mapped as soon as identity sends it.
internal static TenantTokenDenialCause MapExchangeError(string error, string description)
Parameters
error String
description String