22using CodeBeam . UltimateAuth . Core . Contracts ;
33using CodeBeam . UltimateAuth . Core . Domain ;
44using CodeBeam . UltimateAuth . Core . Infrastructure ;
5- using CodeBeam . UltimateAuth . Core . MultiTenancy ;
65using CodeBeam . UltimateAuth . Core . Options ;
76using CodeBeam . UltimateAuth . Server . Abstractions ;
87using CodeBeam . UltimateAuth . Server . Extensions ;
@@ -50,19 +49,20 @@ public async ValueTask<AuthFlowContext> CreateAsync(HttpContext ctx, AuthFlowTyp
5049 var user = ctx . GetUserContext ( ) ;
5150
5251 var clientProfile = await _clientProfileReader . ReadAsync ( ctx ) ;
53- var originalOptions = _serverOptionsProvider . GetOriginal ( ctx ) ;
54- var effectiveOptions = _serverOptionsProvider . GetEffective ( ctx , flowType , clientProfile ) ;
5552
56- var allowedModes = originalOptions . AllowedModes ;
53+ var effective = _serverOptionsProvider . GetEffective ( ctx , clientProfile ) ;
54+ var options = effective . Options ;
5755
58- if ( allowedModes is { Count : > 0 } && ! allowedModes . Contains ( effectiveOptions . Mode ) )
56+ var effectiveMode = effective . Mode ;
57+ var allowedModes = options . AllowedModes ;
58+
59+ if ( allowedModes is { Count : > 0 } && ! allowedModes . Contains ( effectiveMode ) )
5960 {
60- throw new InvalidOperationException ( $ "Auth mode '{ effectiveOptions . Mode } ' is not allowed by server configuration.") ;
61+ throw new InvalidOperationException ( $ "Auth mode '{ effectiveMode } ' is not allowed by server configuration.") ;
6162 }
6263
63- var effectiveMode = effectiveOptions . Mode ;
6464 var primaryTokenKind = _primaryTokenResolver . Resolve ( effectiveMode ) ;
65- var response = _authResponseResolver . Resolve ( effectiveMode , flowType , clientProfile , effectiveOptions ) ;
65+ var response = _authResponseResolver . Resolve ( effectiveMode , flowType , clientProfile , effective ) ;
6666 var deviceInfo = await _deviceResolver . ResolveAsync ( ctx ) ;
6767 var deviceContext = _deviceContextFactory . Create ( deviceInfo ) ;
6868 var returnUrl = await ctx . GetReturnUrlAsync ( ) ;
@@ -78,6 +78,7 @@ public async ValueTask<AuthFlowContext> CreateAsync(HttpContext ctx, AuthFlowTyp
7878 Tenant = tenant ,
7979 SessionId = sessionCtx . SessionId ! . Value ,
8080 Device = deviceContext ,
81+ SessionOptions = options . Session ,
8182 Now = _clock . UtcNow
8283 } ,
8384 ct ) ;
@@ -100,8 +101,7 @@ public async ValueTask<AuthFlowContext> CreateAsync(HttpContext ctx, AuthFlowTyp
100101 user ? . IsAuthenticated ?? false ,
101102 user ? . UserId ,
102103 sessionSecurityContext ,
103- originalOptions ,
104- effectiveOptions ,
104+ options ,
105105 response ,
106106 primaryTokenKind ,
107107 returnUrlInfo
@@ -113,19 +113,19 @@ public async ValueTask<AuthFlowContext> RecreateWithClientProfileAsync(AuthFlowC
113113 var flowType = existing . FlowType ;
114114 var tenant = existing . Tenant ;
115115
116- var originalOptions = existing . OriginalOptions ;
117- var effectiveOptions = _serverOptionsProvider . GetEffective ( tenant , flowType , overriddenProfile ) ;
116+ var effective = _serverOptionsProvider . GetEffective ( tenant , overriddenProfile ) ;
117+ var options = effective . Options ;
118+ var effectiveMode = effective . Mode ;
118119
119- var allowedModes = originalOptions . AllowedModes ;
120+ var allowedModes = options . AllowedModes ;
120121
121- if ( allowedModes is { Count : > 0 } && ! allowedModes . Contains ( effectiveOptions . Mode ) )
122+ if ( allowedModes is { Count : > 0 } && ! allowedModes . Contains ( effectiveMode ) )
122123 {
123- throw new InvalidOperationException ( $ "Auth mode '{ effectiveOptions . Mode } ' is not allowed by server configuration.") ;
124+ throw new InvalidOperationException ( $ "Auth mode '{ effectiveMode } ' is not allowed by server configuration.") ;
124125 }
125126
126- var effectiveMode = effectiveOptions . Mode ;
127127 var primaryTokenKind = _primaryTokenResolver . Resolve ( effectiveMode ) ;
128- var response = _authResponseResolver . Resolve ( effectiveMode , flowType , overriddenProfile , effectiveOptions ) ;
128+ var response = _authResponseResolver . Resolve ( effectiveMode , flowType , overriddenProfile , effective ) ;
129129
130130 var returnUrlInfo = existing . ReturnUrlInfo ;
131131 var deviceContext = existing . Device ;
@@ -140,8 +140,7 @@ public async ValueTask<AuthFlowContext> RecreateWithClientProfileAsync(AuthFlowC
140140 existing . IsAuthenticated ,
141141 existing . UserKey ,
142142 session ,
143- originalOptions ,
144- effectiveOptions ,
143+ options ,
145144 response ,
146145 primaryTokenKind ,
147146 returnUrlInfo
@@ -162,8 +161,7 @@ public ValueTask<AuthFlowContext> RecreateWithDeviceAsync(AuthFlowContext existi
162161 existing . IsAuthenticated ,
163162 existing . UserKey ,
164163 existing . Session ,
165- existing . OriginalOptions ,
166- existing . EffectiveOptions ,
164+ existing . Options ,
167165 existing . Response ,
168166 existing . PrimaryTokenKind ,
169167 existing . ReturnUrlInfo
0 commit comments