Class CompositeAuthenticator
The CompositeAuthenticator
uses a list of injected IAuthenticator to provide support for multiple authentication flows.
Inherited Members
Namespace: Unity.Cloud.Identity
Syntax
public class CompositeAuthenticator : ICompositeAuthenticator, IUrlRedirectionAuthenticator, IAuthenticator, IAccessTokenProvider, IAuthenticationStateProvider, IDisposable
Remarks
The CompositeAuthenticator
uses internally the first IAuthenticator from the injected list that returns a true value when invoking
Examples
Constructors
CompositeAuthenticator(CompositeAuthenticatorSettings)
Provides a ICompositeAuthenticator that accepts a CompositeAuthenticatorSettings to handle and prioritize runtime execution contexts.
Declaration
public CompositeAuthenticator(CompositeAuthenticatorSettings compositeAuthenticatorSettings)
Parameters
Type | Name | Description |
---|---|---|
CompositeAuthenticatorSettings | compositeAuthenticatorSettings | A CompositeAuthenticatorSettings that contains the prioritized list of IAuthenticator. |
Properties
AuthenticationState
Holds the current AuthenticationState
.
Declaration
public AuthenticationState AuthenticationState { get; }
Property Value
Type | Description |
---|---|
AuthenticationState |
Implements
RequiresGUI
Whether the ICompositeAuthenticator implementation requires a graphical user interface (GUI) for the authentication flow.
Declaration
public bool RequiresGUI { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
Remarks
A GUI is required for a user to click login and logout buttons and provide credentials when requested. When no GUI is required, the login is done automatically in the InitializeAsync() method.
Methods
CancelLogin()
Cancels the awaiting login operation.
Declaration
public void CancelLogin()
Implements
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
Dispose()
Disposes IDisposable
references.
Declaration
public void Dispose()
Implements
Dispose(Boolean)
Disposes IDisposable
references internally.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | The Boolean value received from the public |
GetAccessTokenAsync()
Declaration
public Task<string> GetAccessTokenAsync()
Returns
Type | Description |
---|---|
Task<String> |
Implements
HasValidPreconditionsAsync()
Indicates if the IAuthenticator
has valid preconditions to provide authentication in the current execution context.
Declaration
public Task<bool> HasValidPreconditionsAsync()
Returns
Type | Description |
---|---|
Task<Boolean> | A task that when completed indicates if the |
Implements
Remarks
The CompositeAuthenticator always returns false to prevent nested ICompositeAuthenticator architecture.
InitializeAsync()
A task to initialize the AuthenticationState from either cache or direct injection value.
Declaration
public async Task InitializeAsync()
Returns
Type | Description |
---|---|
Task |
Implements
LoginAsync()
Performs a login operation.
Declaration
public Task LoginAsync()
Returns
Type | Description |
---|---|
Task | A task. |
Implements
Exceptions
Type | Condition |
---|---|
InvalidOperationException | |
AuthenticationFailedException |
LogoutAsync(Boolean)
Performs a logout operation.
Declaration
public Task LogoutAsync(bool clearBrowserCache = false)
Parameters
Type | Name | Description |
---|---|---|
Boolean | clearBrowserCache | An optional boolean value that, if set to true, triggers a navigation to the OS default browser to clear any cached session. |
Returns
Type | Description |
---|---|
Task | A task. |
Implements
Remarks
A logout operation clears the user session in the application only. Unless the user manually clears the session in the browser that is used for authentication, a user can get automatically logged in again from cached values, without entering any credentials. Use the clearBrowserCache boolean to also clear the session in the browser to prevent automatic login from a cached session.
Exceptions
Type | Condition |
---|---|
InvalidOperationException |
Events
AuthenticationStateChanged
Triggers when the AuthenticationState of the current user changes.
Declaration
public event Action<AuthenticationState> AuthenticationStateChanged
Event Type
Type | Description |
---|---|
Action<AuthenticationState> |
Implements
Remarks
Subscribers of this event should restrict or allow access to available resources and features based on the returned value.