2
2
using GenHTTP . Api . Protocol ;
3
3
using GenHTTP . Api . Routing ;
4
4
using GenHTTP . Modules . Basics ;
5
- using GenHTTP . Modules . Layouting ;
6
5
using System ;
7
6
using System . Collections . Generic ;
8
7
using System . Threading . Tasks ;
@@ -19,52 +18,22 @@ public sealed class WebAuthenticationConcern : IConcern, IRootPathAppender, IHan
19
18
20
19
public IHandler Parent { get ; }
21
20
22
- public IWebAuthenticationBackend Backend { get ; }
21
+ private SetupConfig ? SetupConfig { get ; }
23
22
24
- //public ISessionNegotiation SessionNegotiation { get; }
25
-
26
- //public string LoginRoute { get; }
27
-
28
- //public bool AllowAnonymous { get; }
29
-
30
- //public string LogoutRoute { get; }
31
-
32
- //public string? RegistrationRoute { get; }
33
-
34
- public IHandler ? SetupHandler { get ; }
35
-
36
- public string ? SetupRoute { get ; }
23
+ private IHandler ? SetupHandler { get ; }
37
24
38
25
#endregion
39
26
40
27
#region Initialization
41
28
42
29
public WebAuthenticationConcern ( IHandler parent , Func < IHandler , IHandler > contentFactory ,
43
- IWebAuthenticationBackend backend , //ISessionNegotiation sessionNegotiation,
44
- //IHandlerBuilder loginHandler, string loginRoute, bool allowAnonymous,
45
- //IHandlerBuilder logoutHandler, string logoutRoute,
46
- //IHandlerBuilder? registrationHandler, string? registrationRoute,
47
- IHandlerBuilder ? setupHandler , string ? setupRoute )
30
+ SetupConfig ? setupConfig )
48
31
{
49
32
Parent = parent ;
50
33
Content = contentFactory ( this ) ;
51
34
52
- Backend = backend ;
53
- //SessionNegotiation = sessionNegotiation;
54
-
55
- //LoginRoute = loginRoute;
56
- //AllowAnonymous = allowAnonymous;
57
-
58
- //LogoutRoute = logoutRoute;
59
-
60
- SetupRoute = setupRoute ;
61
- SetupHandler = setupHandler ? . Build ( this ) ;
62
-
63
- /*if ((registrationRoute != null) && (registrationHandler != null))
64
- {
65
- RegistrationRoute = registrationRoute;
66
- overlay.Add(registrationRoute, registrationHandler);
67
- }*/
35
+ SetupConfig = setupConfig ;
36
+ SetupHandler = setupConfig ? . Handler . Build ( this ) ;
68
37
}
69
38
70
39
#endregion
@@ -79,11 +48,11 @@ public WebAuthenticationConcern(IHandler parent, Func<IHandler, IHandler> conten
79
48
{
80
49
var segment = request . Target . Current ;
81
50
82
- if ( ( SetupRoute != null ) && ( SetupHandler != null ) )
51
+ if ( ( SetupConfig != null ) && ( SetupHandler != null ) )
83
52
{
84
- if ( await Backend . CheckSetupRequired ( request ) )
53
+ if ( await SetupConfig . SetupRequired ( request ) )
85
54
{
86
- if ( segment ? . Value != SetupRoute )
55
+ if ( segment ? . Value != SetupConfig . Route )
87
56
{
88
57
return await Redirect . To ( "{setup}/" , true )
89
58
. Build ( this )
@@ -93,6 +62,8 @@ public WebAuthenticationConcern(IHandler parent, Func<IHandler, IHandler> conten
93
62
{
94
63
request . Target . Advance ( ) ;
95
64
65
+ Setup . SetConfig ( request , SetupConfig ) ;
66
+
96
67
return await SetupHandler . HandleAsync ( request ) ;
97
68
}
98
69
}
@@ -103,14 +74,22 @@ public WebAuthenticationConcern(IHandler parent, Func<IHandler, IHandler> conten
103
74
104
75
public void Append ( PathBuilder path , IRequest request , IHandler ? child = null )
105
76
{
106
- if ( ( child == SetupHandler ) && ( SetupRoute != null ) )
77
+ if ( SetupConfig != null )
107
78
{
108
- path . Preprend ( SetupRoute ) ;
79
+ if ( child == SetupHandler )
80
+ {
81
+ path . Preprend ( SetupConfig . Route ) ;
82
+ }
109
83
}
110
84
}
111
85
112
86
public IHandler ? Find ( string segment )
113
87
{
88
+ if ( segment == "{web-auth}" )
89
+ {
90
+ return this ;
91
+ }
92
+
114
93
if ( segment == "{setup}" )
115
94
{
116
95
return SetupHandler ;
0 commit comments