2022-04-30 23:11:48 +04:00
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
2022-04-30 08:20:17 +04:00
|
|
|
using Ragon.Core;
|
|
|
|
|
|
|
|
|
|
namespace Game.Source;
|
|
|
|
|
|
2022-05-14 10:35:17 +04:00
|
|
|
public class AuthorizerByKey: AuthorizationManager
|
2022-04-30 08:20:17 +04:00
|
|
|
{
|
2022-04-30 23:11:48 +04:00
|
|
|
private Configuration _configuration;
|
2022-05-14 10:35:17 +04:00
|
|
|
public AuthorizerByKey(Configuration configuration)
|
2022-04-30 08:20:17 +04:00
|
|
|
{
|
2022-04-30 23:11:48 +04:00
|
|
|
_configuration = configuration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool OnAuthorize(uint peerId, ref ReadOnlySpan<byte> payload)
|
|
|
|
|
{
|
2022-05-14 10:35:17 +04:00
|
|
|
var key = Encoding.UTF8.GetString(payload);
|
|
|
|
|
return _configuration.Key == key;
|
2022-04-30 08:20:17 +04:00
|
|
|
}
|
|
|
|
|
}
|