Authentication #335
Replies: 4 comments
-
Authentication sequences
interface IAuthenticationService
{
Task<bool> Login(IDispatcher dispatcher, IDictionary<string,string>? credentials= null);
Task<bool> Refresh();
Task<bool> Logout(IDispatcher dispatcher);
} Service method return options:
Implementations:
record CustomAuthenticationSettings
(
Func<IDispatcher, ITokenCache, IDictionary<string,string>, Task<bool>> LoginCallback,
Func<IDispatcher, ITokenCache, Task<boo>>? RefreshCallback = null,
Func<IDispatcher, ITokenCache, Task<bool>>? LogoutCallback = null
)
record CustomAuthenticationService
(
ITokenCache Tokens,
CustomAuthenticationSettings Settings
)
.UseAuthentication( CustomAuthenticationSettings ) Workflow:
record MSALAuthenticationService
(
ITokenCache Tokens,
MSALSetting Settings
) Workflow:
|
Beta Was this translation helpful? Give feedback.
-
Authorization options for service calls
Implementations: record CookieAuthorizationHandler
{
ITokenCache Tokens;
}
record AuthorizationHeaderHandler
{
ITokenCache Tokens;
string AuthorizationTokenName;
} |
Beta Was this translation helpful? Give feedback.
-
****** Ignore for now Authentication WorkflowIAuthenticationService deals with the actual calls to authenticate/refresh, it doesn't help with defining what the user experience should be for login/auth. A typical scenario would be that the app launches and then either goes to a welcome/login page (assuming no cached credentials), after the user logs in, the app redirects to the home page of the app (and removes the login page from any backstack). interface IAuthenticationWorkflow
{
void Start(INavigator navigator);
}
interface IAuthenticationSession
{
Task<bool> Login(IDictionary<string,string> credentials);
Task<bool> Logout();
} Workflow:
record AuthenticationWorkflow
{
IAuthenticationService AuthenticationService,
ITokenCache TokenCache,
string? LoginRoute = null,
Type? LoginView = null,
Type? LoginViewModel = null,
string? HomeRoute = null,
Type? HomeView = null,
Type? HomeViewModel = null,
} AuthenticationWorkflow should listen to TokenCache for a "clear" event in order to redirect user back to login page. |
Beta Was this translation helpful? Give feedback.
-
Token Cacheinterface ITokenCache
{
Task Save(IDictionary<string, string> tokens);
Task Clear();
Task<IDictionary<string,string>> GetAll();
event EventHandler TokensCleared;
} |
Beta Was this translation helpful? Give feedback.
-
Goal: Provide a wrapper around authentication (Eg MSAL, or perhaps a username/password (basic) authentication model)
Authentication & Authorization Requirements
Authentication UI/UX Patterns
Authentication Token Options
App Workflow/Scenarios
Existing cached credentials (token/cookie etc)?
Logout
Service call fails with auth error
Caching Concerns
Beta Was this translation helpful? Give feedback.
All reactions