Skip to content

Commit 841d112

Browse files
author
Vadim Belov
committed
Add refresh token entity and authentication models
- Introduced RefreshToken entity for storing refresh tokens with user association and revocation support. - Added LoginResponse, RefreshTokenRequest, and UsernameLoginRequest models for authentication workflows. - Added GlobalSuppressions.cs to suppress CA1873 warning on AddEasyStack method.
1 parent 57625e2 commit 841d112

5 files changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This file is used by Code Analysis to maintain SuppressMessage
2+
// attributes that are applied to this project.
3+
// Project-level suppressions either have no target or are given
4+
// a specific target and scoped to a namespace, type, member, etc.
5+
6+
using System.Diagnostics.CodeAnalysis;
7+
8+
[assembly: SuppressMessage("Performance", "CA1873:Avoid potentially expensive logging", Justification = "<Pending>", Scope = "member", Target = "~M:EasyExtensions.AspNetCore.Stack.Extensions.HostApplicationBuilderExtensions.AddEasyStack(Microsoft.Extensions.Hosting.IHostApplicationBuilder,System.Action{EasyExtensions.AspNetCore.Stack.Builders.EasyStackOptions})~Microsoft.Extensions.Hosting.IHostApplicationBuilder")]
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Microsoft.EntityFrameworkCore;
2+
using System.ComponentModel.DataAnnotations.Schema;
3+
using EasyExtensions.EntityFrameworkCore.Abstractions;
4+
5+
namespace EasyExtensions.EntityFrameworkCore.Database
6+
{
7+
/// <summary>
8+
/// Represents a refresh token used to obtain new access tokens for a user in authentication workflows.
9+
/// </summary>
10+
/// <remarks>A refresh token is typically issued alongside an access token and allows clients to request
11+
/// new access tokens without requiring the user to re-authenticate. Each refresh token is associated with a
12+
/// specific user and can be revoked to prevent further use.</remarks>
13+
[Table("refresh_tokens")]
14+
[Index(nameof(Token), IsUnique = true)]
15+
public class RefreshToken : BaseEntity<Guid>
16+
{
17+
/// <summary>
18+
/// Gets or sets the unique identifier for the user.
19+
/// </summary>
20+
[Column("user_id")]
21+
public Guid UserId { get; set; }
22+
23+
/// <summary>
24+
/// Gets or sets the authentication token associated with the entity.
25+
/// </summary>
26+
[Column("token")]
27+
public string Token { get; set; } = null!;
28+
29+
/// <summary>
30+
/// Gets or sets the date and time when the entity was revoked. Stored in UTC.
31+
/// </summary>
32+
[Column("revoked_at")]
33+
public DateTime? RevokedAt { get; set; }
34+
}
35+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace EasyExtensions.Models
2+
{
3+
/// <summary>
4+
/// Represents the result of a successful authentication request, including access and refresh tokens.
5+
/// </summary>
6+
public class LoginResponse
7+
{
8+
/// <summary>
9+
/// Gets or sets the access token used for authenticating requests.
10+
/// </summary>
11+
public string AccessToken { get; set; } = null!;
12+
13+
/// <summary>
14+
/// Gets or sets the refresh token used to obtain a new access token when the current token expires.
15+
/// </summary>
16+
public string? RefreshToken { get; set; }
17+
}
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace EasyExtensions.Models
2+
{
3+
/// <summary>
4+
/// Gets or sets the refresh token used to obtain a new access token.
5+
/// </summary>
6+
public class RefreshTokenRequest
7+
{
8+
/// <summary>
9+
/// Gets or sets the refresh token used to obtain a new access token when the current access token expires.
10+
/// </summary>
11+
public string? RefreshToken { get; set; }
12+
}
13+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace EasyExtensions.Models
2+
{
3+
/// <summary>
4+
/// Represents a request to authenticate a user using a username and password.
5+
/// </summary>
6+
public class UsernameLoginRequest
7+
{
8+
/// <summary>
9+
/// Gets or sets the username associated with the account.
10+
/// </summary>
11+
public string Username { get; set; } = null!;
12+
13+
/// <summary>
14+
/// Gets or sets the password associated with the account or resource.
15+
/// </summary>
16+
public string Password { get; set; } = null!;
17+
}
18+
}

0 commit comments

Comments
 (0)