diff --git a/dotnet/AipsCore/Application/Abstract/UserContext/IRefreshTokenRepository.cs b/dotnet/AipsCore/Application/Abstract/UserContext/IRefreshTokenRepository.cs new file mode 100644 index 0000000..a2b88dc --- /dev/null +++ b/dotnet/AipsCore/Application/Abstract/UserContext/IRefreshTokenRepository.cs @@ -0,0 +1,12 @@ +using AipsCore.Application.Common.Authentication.Models; +using AipsCore.Domain.Models.User.ValueObjects; + +namespace AipsCore.Application.Abstract.UserContext; + +public interface IRefreshTokenRepository +{ + Task AddAsync(string token, UserId userId, CancellationToken cancellationToken = default); + Task GetByValueAsync(string token, CancellationToken cancellationToken = default); + Task RevokeAsync(string token, CancellationToken cancellationToken = default); + Task RevokeAllAsync(UserId userId, CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/dotnet/AipsCore/Application/Abstract/UserContext/ITokenProvider.cs b/dotnet/AipsCore/Application/Abstract/UserContext/ITokenProvider.cs index 26932bf..15de6e8 100644 --- a/dotnet/AipsCore/Application/Abstract/UserContext/ITokenProvider.cs +++ b/dotnet/AipsCore/Application/Abstract/UserContext/ITokenProvider.cs @@ -5,5 +5,6 @@ namespace AipsCore.Application.Abstract.UserContext; public interface ITokenProvider { - string Generate(User user, IList roles); + string GenerateAccessToken(User user, IList roles); + string GenerateRefreshToken(); } \ No newline at end of file diff --git a/dotnet/AipsCore/Application/Common/Authentication/Dtos/LogInUserResultDto.cs b/dotnet/AipsCore/Application/Common/Authentication/Dtos/LogInUserResultDto.cs new file mode 100644 index 0000000..43317eb --- /dev/null +++ b/dotnet/AipsCore/Application/Common/Authentication/Dtos/LogInUserResultDto.cs @@ -0,0 +1,3 @@ +namespace AipsCore.Application.Common.Authentication.Dtos; + +public record LogInUserResultDto(string AccessToken, string RefreshToken); \ No newline at end of file diff --git a/dotnet/AipsCore/Application/Common/Authentication/IAuthService.cs b/dotnet/AipsCore/Application/Common/Authentication/IAuthService.cs index f5c3215..abd9b4d 100644 --- a/dotnet/AipsCore/Application/Common/Authentication/IAuthService.cs +++ b/dotnet/AipsCore/Application/Common/Authentication/IAuthService.cs @@ -1,3 +1,4 @@ +using AipsCore.Application.Common.Authentication.Models; using AipsCore.Domain.Models.User; namespace AipsCore.Application.Common.Authentication; @@ -6,4 +7,5 @@ public interface IAuthService { Task SignUpWithPasswordAsync(User user, string password, CancellationToken cancellationToken = default); Task LoginWithEmailAndPasswordAsync(string email, string password, CancellationToken cancellationToken = default); + Task LoginWithRefreshTokenAsync(RefreshToken refreshToken, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/dotnet/AipsCore/Application/Common/Authentication/Models/AccessToken.cs b/dotnet/AipsCore/Application/Common/Authentication/Models/AccessToken.cs new file mode 100644 index 0000000..4ac3966 --- /dev/null +++ b/dotnet/AipsCore/Application/Common/Authentication/Models/AccessToken.cs @@ -0,0 +1,3 @@ +namespace AipsCore.Application.Common.Authentication.Models; + +public record AccessToken(string Value); \ No newline at end of file diff --git a/dotnet/AipsCore/Application/Common/Authentication/Models/RefreshToken.cs b/dotnet/AipsCore/Application/Common/Authentication/Models/RefreshToken.cs new file mode 100644 index 0000000..7ec8786 --- /dev/null +++ b/dotnet/AipsCore/Application/Common/Authentication/Models/RefreshToken.cs @@ -0,0 +1,5 @@ +using AipsCore.Domain.Models.User.ValueObjects; + +namespace AipsCore.Application.Common.Authentication.Models; + +public record RefreshToken(string Value, string UserId, DateTime ExpiresAt); \ No newline at end of file diff --git a/dotnet/AipsCore/Application/Common/Authentication/Token.cs b/dotnet/AipsCore/Application/Common/Authentication/Token.cs deleted file mode 100644 index 18d5af1..0000000 --- a/dotnet/AipsCore/Application/Common/Authentication/Token.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace AipsCore.Application.Common.Authentication; - -public record Token(string Value); \ No newline at end of file