From 0fa768556aca00f4346ccd71917fad048def6323 Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 30 May 2024 08:22:50 +0000 Subject: Move around some projects, further cleanup pending --- .../Services/TokenService.cs | 29 ---------------------- 1 file changed, 29 deletions(-) delete mode 100644 Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs (limited to 'Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs') diff --git a/Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs b/Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs deleted file mode 100644 index cf79aae..0000000 --- a/Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace LibMatrix.HomeserverEmulator.Services; - -public class TokenService{ - public string? GetAccessTokenOrNull(HttpContext ctx) { - //qry - if (ctx.Request.Query.TryGetValue("access_token", out var token)) { - return token; - } - //header - if (ctx.Request.Headers.TryGetValue("Authorization", out var auth)) { - var parts = auth.ToString().Split(' '); - if (parts is ["Bearer", _]) { - return parts[1]; - } - } - return null; - } - - public string GetAccessToken(HttpContext ctx) { - return GetAccessTokenOrNull(ctx) ?? throw new MatrixException() { - ErrorCode = MatrixException.ErrorCodes.M_UNKNOWN_TOKEN, - Error = "Missing token" - }; - } - - public string? GenerateServerName(HttpContext ctx) { - return ctx.Request.Host.ToString(); - } -} \ No newline at end of file -- cgit 1.4.1