feat : 토큰 인증 RestApi 구현 / Token기반 haskKey구현 / Dummy, User Token체크 분기

This commit is contained in:
qornwh1
2026-03-04 15:53:15 +09:00
parent 053c5d23b9
commit 343ea43a03
12 changed files with 187 additions and 16 deletions

View File

@@ -0,0 +1,12 @@
namespace MMOserver.Utils;
public abstract class Singleton<T> where T : Singleton<T>, new()
{
private static readonly Lazy<T> instance = new Lazy<T>(static () => new T(), LazyThreadSafetyMode.ExecutionAndPublication);
public static T Instance => instance.Value;
protected Singleton()
{
}
}

View File

@@ -0,0 +1,21 @@
using System.Collections.Concurrent;
namespace MMOserver.Utils;
public class UuidGeneratorManager : Singleton<UuidGeneratorManager>
{
private long counter = 0;
private readonly ConcurrentDictionary<string, long> tokenMap = new();
// string token → 고유 long ID 변환 (멀티스레드 안전)
// 동일 token은 항상 같은 ID 반환
public long GetOrCreate(string token)
{
return tokenMap.GetOrAdd(token, _ => Interlocked.Increment(ref counter));
}
public bool TryGet(string token, out long id)
{
return tokenMap.TryGetValue(token, out id);
}
}