mirror of
https://git.recroomarchive.org/RecRoomArchive/RRAC.git
synced 2026-09-08 14:41:25 -07:00
Initialize repository
Added basic info to get in game for like...August 2016 ;-; It's not much but it's a start
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
|
||||
namespace RecRoomArchive.Services
|
||||
{
|
||||
public class AuthorizationService
|
||||
{
|
||||
private static readonly string Key = "hello diddy blud. you need to replace me. or not, really it doesnt matter...I forgot how long a token like this has to be so I'm just gonna run my mouth. Hi. This is RecRoomArchive. You may wonder why we have JWT tokens in a localhost server, and that's because 2020 requires it and stuff. and 2019. Especially 2021. I wonder if I will be doing 2021 or not...";
|
||||
|
||||
public string GenerateToken(ulong id)
|
||||
{
|
||||
JwtSecurityTokenHandler handler = new();
|
||||
|
||||
List<Claim> claims = new List<Claim>()
|
||||
{
|
||||
new(ClaimTypes.NameIdentifier, id.ToString()),
|
||||
new(ClaimTypes.Role, "gameClient")
|
||||
};
|
||||
|
||||
SecurityTokenDescriptor tokenDescriptor = new SecurityTokenDescriptor()
|
||||
{
|
||||
Subject = new ClaimsIdentity(claims),
|
||||
Expires = DateTime.UtcNow.Add(TimeSpan.FromHours(12)),
|
||||
Issuer = "https://recroomarchive.org/",
|
||||
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Key)), SecurityAlgorithms.HmacSha256)
|
||||
};
|
||||
|
||||
JwtSecurityToken token = handler.CreateJwtSecurityToken(tokenDescriptor);
|
||||
return handler.WriteToken(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user