File tree Expand file tree Collapse file tree 10 files changed +112
-151
lines changed Expand file tree Collapse file tree 10 files changed +112
-151
lines changed Original file line number Diff line number Diff line change @@ -424,7 +424,11 @@ impl UserEmailMutations {
424
424
425
425
if !skip_policy_check {
426
426
let mut policy = state. policy ( ) . await ?;
427
- let res = policy. evaluate_email ( & input. email ) . await ?;
427
+ let res = policy
428
+ . evaluate_email ( mas_policy:: EmailInput {
429
+ email : & input. email ,
430
+ } )
431
+ . await ?;
428
432
if !res. valid ( ) {
429
433
return Ok ( AddEmailPayload :: Denied {
430
434
violations : res. violations ,
@@ -610,7 +614,11 @@ impl UserEmailMutations {
610
614
611
615
// Check if the email address is allowed by the policy
612
616
let mut policy = state. policy ( ) . await ?;
613
- let res = policy. evaluate_email ( & input. email ) . await ?;
617
+ let res = policy
618
+ . evaluate_email ( mas_policy:: EmailInput {
619
+ email : & input. email ,
620
+ } )
621
+ . await ?;
614
622
if !res. valid ( ) {
615
623
return Ok ( StartEmailAuthenticationPayload :: Denied {
616
624
violations : res. violations ,
Original file line number Diff line number Diff line change @@ -226,7 +226,12 @@ pub(crate) async fn complete(
226
226
227
227
// Run through the policy
228
228
let res = policy
229
- . evaluate_authorization_grant ( & grant, client, & browser_session. user )
229
+ . evaluate_authorization_grant ( mas_policy:: AuthorizationGrantInput {
230
+ user : Some ( & browser_session. user ) ,
231
+ client,
232
+ scope : & grant. scope ,
233
+ grant_type : mas_policy:: GrantType :: AuthorizationCode ,
234
+ } )
230
235
. await ?;
231
236
232
237
if !res. valid ( ) {
Original file line number Diff line number Diff line change @@ -111,7 +111,12 @@ pub(crate) async fn get(
111
111
let ( csrf_token, cookie_jar) = cookie_jar. csrf_token ( & clock, & mut rng) ;
112
112
113
113
let res = policy
114
- . evaluate_authorization_grant ( & grant, & client, & session. user )
114
+ . evaluate_authorization_grant ( mas_policy:: AuthorizationGrantInput {
115
+ user : Some ( & session. user ) ,
116
+ client : & client,
117
+ scope : & grant. scope ,
118
+ grant_type : mas_policy:: GrantType :: AuthorizationCode ,
119
+ } )
115
120
. await ?;
116
121
117
122
if res. valid ( ) {
@@ -185,7 +190,12 @@ pub(crate) async fn post(
185
190
. ok_or ( RouteError :: NoSuchClient ) ?;
186
191
187
192
let res = policy
188
- . evaluate_authorization_grant ( & grant, & client, & session. user )
193
+ . evaluate_authorization_grant ( mas_policy:: AuthorizationGrantInput {
194
+ user : Some ( & session. user ) ,
195
+ client : & client,
196
+ scope : & grant. scope ,
197
+ grant_type : mas_policy:: GrantType :: AuthorizationCode ,
198
+ } )
189
199
. await ?;
190
200
191
201
if !res. valid ( ) {
Original file line number Diff line number Diff line change @@ -82,7 +82,12 @@ pub(crate) async fn get(
82
82
83
83
// Evaluate the policy
84
84
let res = policy
85
- . evaluate_device_code_grant ( & grant, & client, & session. user )
85
+ . evaluate_authorization_grant ( mas_policy:: AuthorizationGrantInput {
86
+ grant_type : mas_policy:: GrantType :: DeviceCode ,
87
+ client : & client,
88
+ scope : & grant. scope ,
89
+ user : Some ( & session. user ) ,
90
+ } )
86
91
. await ?;
87
92
if !res. valid ( ) {
88
93
warn ! ( violation = ?res, "Device code grant for client {} denied by policy" , client. id) ;
@@ -157,7 +162,12 @@ pub(crate) async fn post(
157
162
158
163
// Evaluate the policy
159
164
let res = policy
160
- . evaluate_device_code_grant ( & grant, & client, & session. user )
165
+ . evaluate_authorization_grant ( mas_policy:: AuthorizationGrantInput {
166
+ grant_type : mas_policy:: GrantType :: DeviceCode ,
167
+ client : & client,
168
+ scope : & grant. scope ,
169
+ user : Some ( & session. user ) ,
170
+ } )
161
171
. await ?;
162
172
if !res. valid ( ) {
163
173
warn ! ( violation = ?res, "Device code grant for client {} denied by policy" , client. id) ;
Original file line number Diff line number Diff line change @@ -244,7 +244,11 @@ pub(crate) async fn post(
244
244
}
245
245
}
246
246
247
- let res = policy. evaluate_client_registration ( & metadata) . await ?;
247
+ let res = policy
248
+ . evaluate_client_registration ( mas_policy:: ClientRegistrationInput {
249
+ client_metadata : & metadata,
250
+ } )
251
+ . await ?;
248
252
if !res. valid ( ) {
249
253
return Err ( RouteError :: PolicyDenied ( res. violations ) ) ;
250
254
}
Original file line number Diff line number Diff line change @@ -676,7 +676,12 @@ async fn client_credentials_grant(
676
676
677
677
// Make the request go through the policy engine
678
678
let res = policy
679
- . evaluate_client_credentials_grant ( & scope, client)
679
+ . evaluate_authorization_grant ( mas_policy:: AuthorizationGrantInput {
680
+ user : None ,
681
+ client,
682
+ scope : & scope,
683
+ grant_type : mas_policy:: GrantType :: ClientCredentials ,
684
+ } )
680
685
. await ?;
681
686
if !res. valid ( ) {
682
687
return Err ( RouteError :: DeniedByPolicy ( res. violations ) ) ;
Original file line number Diff line number Diff line change @@ -441,7 +441,11 @@ pub(crate) async fn get(
441
441
}
442
442
443
443
let res = policy
444
- . evaluate_upstream_oauth_register ( & localpart, None )
444
+ . evaluate_register ( mas_policy:: RegisterInput {
445
+ registration_method : mas_policy:: RegistrationMethod :: UpstreamOAuth2 ,
446
+ username : & localpart,
447
+ email : None ,
448
+ } )
445
449
. await ?;
446
450
447
451
if res. valid ( ) {
@@ -752,8 +756,13 @@ pub(crate) async fn post(
752
756
753
757
// Policy check
754
758
let res = policy
755
- . evaluate_upstream_oauth_register ( & username, email. as_deref ( ) )
759
+ . evaluate_register ( mas_policy:: RegisterInput {
760
+ registration_method : mas_policy:: RegistrationMethod :: UpstreamOAuth2 ,
761
+ username : & username,
762
+ email : email. as_deref ( ) ,
763
+ } )
756
764
. await ?;
765
+
757
766
if !res. valid ( ) {
758
767
let form_state =
759
768
res. violations
Original file line number Diff line number Diff line change @@ -233,7 +233,11 @@ pub(crate) async fn post(
233
233
}
234
234
235
235
let res = policy
236
- . evaluate_register ( & form. username , & form. email )
236
+ . evaluate_register ( mas_policy:: RegisterInput {
237
+ registration_method : mas_policy:: RegistrationMethod :: Password ,
238
+ username : & form. username ,
239
+ email : Some ( & form. email ) ,
240
+ } )
237
241
. await ?;
238
242
239
243
for violation in res. violations {
You can’t perform that action at this time.
0 commit comments