@@ -32,32 +32,40 @@ public void OnAuthorization(AuthorizationFilterContext context)
32
32
return ;
33
33
}
34
34
35
+ var clientId = user . GetCustomClaim ( StrDssClaimTypes . ClientId ) ;
36
+
35
37
var identityProviderNm = user . GetCustomClaim ( StrDssClaimTypes . IdentityProvider ) ;
38
+
39
+ if ( identityProviderNm == "" && clientId != "" )
40
+ {
41
+ identityProviderNm = StrDssIdProviders . Aps ;
42
+ }
43
+
36
44
var displayName = user . GetCustomClaim ( StrDssClaimTypes . DisplayName ) ;
37
45
38
- string userGuid ;
46
+ string userId ;
39
47
switch ( identityProviderNm )
40
48
{
41
49
case StrDssIdProviders . Idir :
42
- userGuid = user . GetCustomClaim ( StrDssClaimTypes . IdirUserGuid ) ;
50
+ userId = user . GetCustomClaim ( StrDssClaimTypes . IdirUserGuid ) ;
43
51
break ;
44
52
case StrDssIdProviders . BceidBusiness :
45
- userGuid = user . GetCustomClaim ( StrDssClaimTypes . BceidUserGuid ) ;
53
+ userId = user . GetCustomClaim ( StrDssClaimTypes . BceidUserGuid ) ;
46
54
break ;
47
55
case StrDssIdProviders . StrDss :
48
- userGuid = user . GetCustomClaim ( StrDssClaimTypes . StrDssUserGuid ) ;
56
+ userId = user . GetCustomClaim ( StrDssClaimTypes . StrDssUserGuid ) ;
49
57
break ;
50
58
case StrDssIdProviders . Aps :
51
- userGuid = user . GetCustomClaim ( StrDssClaimTypes . ClientId ) ;
59
+ userId = clientId ;
52
60
break ;
53
61
default :
54
- userGuid = "" ;
62
+ userId = "Unknown " ;
55
63
break ;
56
64
}
57
65
58
66
if ( _permissions . Length == 0 )
59
67
{
60
- _logger . LogInformation ( $ "[AUTH] User '{ userGuid } ' is authorized to access { context . ActionDescriptor . DisplayName } from IP address { ip } .") ;
68
+ _logger . LogInformation ( $ "[AUTH] User '{ userId } ' is authorized to access { context . ActionDescriptor . DisplayName } from IP address { ip } .") ;
61
69
return ;
62
70
}
63
71
@@ -74,12 +82,12 @@ public void OnAuthorization(AuthorizationFilterContext context)
74
82
75
83
if ( ! hasPermission )
76
84
{
77
- _logger . LogInformation ( $ "[AUTH] User '{ userGuid } ' does not have permission to access { context . ActionDescriptor . DisplayName } from IP address { ip } .") ;
85
+ _logger . LogInformation ( $ "[AUTH] User '{ userId } ' does not have permission to access { context . ActionDescriptor . DisplayName } from IP address { ip } .") ;
78
86
context . Result = new UnauthorizedResult ( ) ; //401
79
87
return ;
80
88
}
81
89
82
- _logger . LogInformation ( $ "[AUTH] User '{ userGuid } ' is authorized to access { context . ActionDescriptor . DisplayName } from IP address { ip } .") ;
90
+ _logger . LogInformation ( $ "[AUTH] User '{ userId } ' is authorized to access { context . ActionDescriptor . DisplayName } from IP address { ip } .") ;
83
91
}
84
92
}
85
93
}
0 commit comments