|
1 |
| -using System.Threading.Tasks; |
2 |
| - |
3 |
| -using GenHTTP.Api.Content; |
4 |
| -using GenHTTP.Api.Content.Authentication; |
5 |
| -using GenHTTP.Api.Protocol; |
6 |
| - |
7 |
| -using GenHTTP.Modules.Authentication.Web.Controllers; |
8 |
| -using GenHTTP.Modules.Controllers; |
9 |
| -using GenHTTP.Modules.IO; |
10 |
| - |
11 |
| -namespace GenHTTP.Modules.Authentication.Web.Integration |
12 |
| -{ |
13 |
| - |
14 |
| - public class SimpleIntegrationAdapter : IWebAuthIntegration |
15 |
| - { |
16 |
| - private bool _AllowAnonymous; |
17 |
| - |
18 |
| - private string _SetupRoute, _LoginRoute, _ResourceRoute; |
19 |
| - |
20 |
| - bool IWebAuthIntegration.AllowAnonymous { get => _AllowAnonymous; } |
21 |
| - |
22 |
| - string IWebAuthIntegration.SetupRoute { get => _SetupRoute; } |
23 |
| - |
24 |
| - string IWebAuthIntegration.LoginRoute { get => _LoginRoute; } |
25 |
| - |
26 |
| - string IWebAuthIntegration.ResourceRoute { get => _ResourceRoute; } |
27 |
| - |
28 |
| - public IHandlerBuilder SetupHandler { get; private set; } |
29 |
| - |
30 |
| - public IHandlerBuilder LoginHandler { get; private set; } |
31 |
| - |
32 |
| - public IHandlerBuilder ResourceHandler { get; private set; } |
33 |
| - |
34 |
| - private ISimpleWebAuthIntegration SimpleIntegration { get; } |
35 |
| - |
36 |
| - public SimpleIntegrationAdapter(ISimpleWebAuthIntegration simpleIntegration) |
37 |
| - { |
38 |
| - SimpleIntegration = simpleIntegration; |
39 |
| - |
40 |
| - _AllowAnonymous = simpleIntegration.AllowAnonymous; |
41 |
| - |
42 |
| - _SetupRoute = simpleIntegration.SetupRoute; |
43 |
| - _LoginRoute = simpleIntegration.LoginRoute; |
44 |
| - _ResourceRoute = simpleIntegration.ResourceRoute; |
45 |
| - |
46 |
| - SetupHandler = Controller.From(new SetupController((r, u, p) => simpleIntegration.PerformSetup(r, u, p))); |
47 |
| - LoginHandler = Controller.From(new LoginController((r, u, p) => simpleIntegration.PerformLogin(r, u, p))); |
48 |
| - |
49 |
| - ResourceHandler = Resources.From(ResourceTree.FromAssembly("Resources")); |
50 |
| - } |
51 |
| - |
52 |
| - public ValueTask<bool> CheckSetupRequired(IRequest request) => SimpleIntegration.CheckSetupRequired(request); |
53 |
| - |
54 |
| - public ValueTask<string> StartSessionAsync(IRequest request, IUser user) => SimpleIntegration.StartSessionAsync(request, user); |
55 |
| - |
56 |
| - public ValueTask<IUser?> VerifyTokenAsync(string sessionToken) => SimpleIntegration.VerifyTokenAsync(sessionToken); |
57 |
| - |
58 |
| - } |
59 |
| - |
60 |
| -} |
| 1 | +using System.Threading.Tasks; |
| 2 | + |
| 3 | +using GenHTTP.Api.Content; |
| 4 | +using GenHTTP.Api.Content.Authentication; |
| 5 | +using GenHTTP.Api.Protocol; |
| 6 | + |
| 7 | +using GenHTTP.Modules.Authentication.Web.Controllers; |
| 8 | +using GenHTTP.Modules.Controllers; |
| 9 | +using GenHTTP.Modules.IO; |
| 10 | + |
| 11 | +namespace GenHTTP.Modules.Authentication.Web.Integration |
| 12 | +{ |
| 13 | + |
| 14 | + public class SimpleIntegrationAdapter : IWebAuthIntegration |
| 15 | + { |
| 16 | + private readonly bool _AllowAnonymous; |
| 17 | + |
| 18 | + private readonly string _SetupRoute, _LoginRoute, _ResourceRoute; |
| 19 | + |
| 20 | + bool IWebAuthIntegration.AllowAnonymous { get => _AllowAnonymous; } |
| 21 | + |
| 22 | + string IWebAuthIntegration.SetupRoute { get => _SetupRoute; } |
| 23 | + |
| 24 | + string IWebAuthIntegration.LoginRoute { get => _LoginRoute; } |
| 25 | + |
| 26 | + string IWebAuthIntegration.ResourceRoute { get => _ResourceRoute; } |
| 27 | + |
| 28 | + public IHandlerBuilder SetupHandler { get; private set; } |
| 29 | + |
| 30 | + public IHandlerBuilder LoginHandler { get; private set; } |
| 31 | + |
| 32 | + public IHandlerBuilder ResourceHandler { get; private set; } |
| 33 | + |
| 34 | + private ISimpleWebAuthIntegration SimpleIntegration { get; } |
| 35 | + |
| 36 | + public SimpleIntegrationAdapter(ISimpleWebAuthIntegration simpleIntegration) |
| 37 | + { |
| 38 | + SimpleIntegration = simpleIntegration; |
| 39 | + |
| 40 | + _AllowAnonymous = simpleIntegration.AllowAnonymous; |
| 41 | + |
| 42 | + _SetupRoute = simpleIntegration.SetupRoute; |
| 43 | + _LoginRoute = simpleIntegration.LoginRoute; |
| 44 | + _ResourceRoute = simpleIntegration.ResourceRoute; |
| 45 | + |
| 46 | + SetupHandler = Controller.From(new SetupController((r, u, p) => simpleIntegration.PerformSetup(r, u, p))); |
| 47 | + LoginHandler = Controller.From(new LoginController((r, u, p) => simpleIntegration.PerformLogin(r, u, p))); |
| 48 | + |
| 49 | + ResourceHandler = Resources.From(ResourceTree.FromAssembly("Resources")); |
| 50 | + } |
| 51 | + |
| 52 | + public ValueTask<bool> CheckSetupRequired(IRequest request) => SimpleIntegration.CheckSetupRequired(request); |
| 53 | + |
| 54 | + public ValueTask<string> StartSessionAsync(IRequest request, IUser user) => SimpleIntegration.StartSessionAsync(request, user); |
| 55 | + |
| 56 | + public ValueTask<IUser?> VerifyTokenAsync(string sessionToken) => SimpleIntegration.VerifyTokenAsync(sessionToken); |
| 57 | + |
| 58 | + } |
| 59 | + |
| 60 | +} |
0 commit comments