New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#214 authorization improvements #2659
#214 authorization improvements #2659
Conversation
{ | ||
throw new AbpAuthorizationException("Authorization failed! User has not logged in."); | ||
throw new AbpAuthorizationException("Authorization failed! Given roles has not granted: " + authorizationAttribute.Roles); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @mperk
Policy
and Roles
should be combined, which means we have to check them together, We can build a combination of Policy
and Roles
.
await _authorizationService.CheckAsync(authorizationPolicy);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because AuthorizationPolicyBuilder
can also add AuthenticationSchemes
, we should also test it. As mentioned in #214
- [ ] MethodInvocationAuthorizationService should also evaluate the auth schema (not sure) .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok thank you for quick reply. I will research and develop
public async Task Should_Not_Allow_To_Call_Method_If_Has_No_Role_ProtectedByRole_Async() | ||
{ | ||
await Assert.ThrowsAsync<AbpAuthorizationException>(async () => | ||
{ | ||
await _myAuthorizedService1.ProtectedByRole().ConfigureAwait(false); | ||
}).ConfigureAwait(false); | ||
} | ||
|
||
[Fact] | ||
public async Task Should_Allow_To_Call_Method_If_Has_No_Role_ProtectedByRole_Async() | ||
{ | ||
int result = await _myAuthorizedService1.ProtectedByRole().ConfigureAwait(false); | ||
result.ShouldBe(42); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await _myAuthorizedService1.ProtectedByRole().ConfigureAwait(false);
I guess one of the unit test methods will fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is fail. I am still developing for that. Had very little.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @maliming ,
I finished finally. You can check.
hi @mperk Regarding
Will If we want to handle |
Very good. Thanks. |
As I see, some unit tests are failing.
|
@hikalkan I fixed the unit tests. |
Thanks to both of you :) |
Resolve first item in #214
MethodInvocationAuthorizationService should check Roles