Skip to content

Commit

Permalink
Updated the ISSOService to support querying all provider tokens, and …
Browse files Browse the repository at this point in the history
…refreshing them, when expired. Closes #48.
  • Loading branch information
jezzsantos committed Aug 15, 2024
1 parent 1f2a6d5 commit ba1b752
Show file tree
Hide file tree
Showing 48 changed files with 1,592 additions and 255 deletions.
47 changes: 37 additions & 10 deletions src/Application.Interfaces/Audits.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 19 additions & 10 deletions src/Application.Interfaces/Audits.resx
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
</value>
</resheader>
<data name="PasswordCredentialsApplication_Authenticate_AccountSuspended" xml:space="preserve">
<value>Authentication.Failed.AccountSuspended</value>
<value>Authentication.Password.Failed.AccountSuspended</value>
</data>
<data name="PasswordCredentialsApplication_Authenticate_AccountLocked" xml:space="preserve">
<value>Authentication.Failed.AccountLocked</value>
<value>Authentication.Password.Failed.AccountLocked</value>
</data>
<data name="PasswordCredentialsApplication_Authenticate_InvalidCredentials" xml:space="preserve">
<value>Authentication.Failed.InvalidCredentials</value>
<value>Authentication.Password.Failed.InvalidCredentials</value>
</data>
<data name="PasswordCredentialsApplication_Authenticate_BeforeVerified" xml:space="preserve">
<value>Authentication.Failed.BeforeVerified</value>
<value>Authentication.Password.Failed.BeforeVerified</value>
</data>
<data name="PasswordCredentialsApplication_Authenticate_Succeeded" xml:space="preserve">
<value>Authentication.Passed</value>
<value>Authentication.Password.Passed</value>
</data>
<data name="EndUsersApplication_User_Registered_TermsAccepted" xml:space="preserve">
<value>EndUser.Registered.TermsAccepted</value>
Expand All @@ -58,10 +58,10 @@
<value>SingleSignOn.AutoRegistered</value>
</data>
<data name="SingleSignOnApplication_Authenticate_AccountSuspended" xml:space="preserve">
<value>Authentication.Failed.AccountSuspended</value>
<value>Authentication.SSO.Failed.AccountSuspended</value>
</data>
<data name="SingleSignOnApplication_Authenticate_Succeeded" xml:space="preserve">
<value>Authentication.Passed</value>
<value>Authentication.SSO.Passed</value>
</data>
<data name="CSRFMiddleware_CSRFProtection_Failed" xml:space="preserve">
<value>CSRFProtection.Failed</value>
Expand All @@ -85,12 +85,21 @@
<value>Organization.Deleted</value>
</data>
<data name="APIKeysApplication_Authenticate_AccountSuspended" xml:space="preserve">
<value>Authentication.Failed.AccountSuspended</value>
<value>Authentication.APIKey.Failed.AccountSuspended</value>
</data>
<data name="APIKeysApplication_Authenticate_Succeeded" xml:space="preserve">
<value>Authentication.Passed</value>
<value>Authentication.APIKey.Passed</value>
</data>
<data name="MailgunApi_WebhookAuthentication_Failed" xml:space="preserve">
<value>Mailgun.Authentication.Failed</value>
<value>Authentication.Mailgun.Failed</value>
</data>
<data name="SingleSignOnApplication_Refresh_Succeeded" xml:space="preserve">
<value>Authentication.SSO.Refreshed.Passed</value>
</data>
<data name="AuthTokensApplication_Refresh_Succeeded" xml:space="preserve">
<value>Authentication.Any.Refreshed.Passed</value>
</data>
<data name="SingleSignOnApplication_Refresh_AccountSuspended" xml:space="preserve">
<value>Authentication.SSO.Refreshed.Failed.AccountSuspended</value>
</data>
</root>
23 changes: 18 additions & 5 deletions src/Application.Resources.Shared/Identity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,29 @@ namespace Application.Resources.Shared;

public class AuthenticateTokens
{
public required AuthenticateToken AccessToken { get; set; }
public required AuthenticationToken AccessToken { get; set; }

public required AuthenticateToken RefreshToken { get; set; }
public required AuthenticationToken RefreshToken { get; set; }

public required string UserId { get; set; }
}

public class AuthenticateToken
public class ProviderAuthenticationTokens
{
public required DateTime ExpiresOn { get; set; }
public required AuthenticationToken AccessToken { get; set; }

public required List<AuthenticationToken> OtherTokens { get; set; }

public required string Provider { get; set; }

public required AuthenticationToken? RefreshToken { get; set; }
}

public class AuthenticationToken
{
public required DateTime? ExpiresOn { get; set; }

public required TokenType Type { get; set; }

public required string Value { get; set; }
}
Expand Down Expand Up @@ -49,7 +62,7 @@ public AuthToken(TokenType type, string value, DateTime? expiresOn)

public enum TokenType
{
OtherToken = 0,
AccessToken = 1,
RefreshToken = 2,
IdToken = 3
}
15 changes: 15 additions & 0 deletions src/Application.Services.Shared/ISSOService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Application.Interfaces;
using Application.Resources.Shared;
using Common;

namespace Application.Services.Shared;

public interface ISSOService
{
Task<Result<IReadOnlyList<ProviderAuthenticationTokens>, Error>> GetTokensAsync(ICallerContext caller,
string userId,
CancellationToken cancellationToken);

Task<Result<ProviderAuthenticationTokens, Error>> RefreshTokenAsync(ICallerContext caller, string userId,
string providerName, string refreshToken, CancellationToken cancellationToken);
}
Loading

0 comments on commit ba1b752

Please sign in to comment.