41 lines
1.0 KiB
C#
41 lines
1.0 KiB
C#
using System;
|
|
using System.Data.SqlClient;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SecureCore.Authentication
|
|
{
|
|
public class SessionManager
|
|
{
|
|
private int SessionKeySize { get; } = 64; //n bytes
|
|
private string ConnectionString { get; set; }
|
|
|
|
public SessionManager()
|
|
{
|
|
if (AppSettingsManager.TryGetConnectionStringByName("MainDataConnectionString", out string connection))
|
|
ConnectionString = connection;
|
|
else
|
|
throw new Exception("Failed to get connection string.");
|
|
}
|
|
|
|
public string CreateSessionToken()
|
|
{
|
|
var token = new byte[SessionKeySize];
|
|
|
|
ByteGenerator.GetRandomBytes(ref token);
|
|
|
|
return Convert.ToBase64String(token);
|
|
}
|
|
|
|
//public string CreatePasswordRecoveryKey(string userName)
|
|
//{
|
|
|
|
// using (var connection = new SqlConnection(ConnectionString))
|
|
// {
|
|
|
|
// }
|
|
//}
|
|
}
|
|
}
|