-
Notifications
You must be signed in to change notification settings - Fork 6k
Add authorize() DSL method that accepts HttpMethod #8350
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
Add authorize() DSL method that accepts HttpMethod #8350
Conversation
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.
Thanks for the PR @adamu.
There are some nice changes here that are not directly related to the reported issue.
It would be best if those changes were in separate commits to give a clearer picture to someone viewing the commit history.
One example is extracting PATTERN_TYPE
.
Another example is using named arguments. While this is necessary given the changes to PatternAuthorizationRule
it may not be obvious to someone viewing the history of this file.
I can see this broken into 3 commits, example titles
"Extract pattern type in request matcher DSL"
"Use named arguments in Kotlin authorization rule"
"Add authorize() DSL method that accepts HttpMethod"
All commits can still be part of this PR.
I have also left a few comments inline.
...src/test/kotlin/org/springframework/security/config/web/servlet/AuthorizeRequestsDslTests.kt
Show resolved
Hide resolved
...src/test/kotlin/org/springframework/security/config/web/servlet/AuthorizeRequestsDslTests.kt
Outdated
Show resolved
Hide resolved
@eleftherias I have split the PR into 3 commits, using your suggested titles. I also added the extra test. However, there is some behaviour I am unsure about. For http {
authorizeRequests {
authorize("/no_specified_method", permitAll)
authorize(HttpMethod.GET, "/specified_method", permitAll)
authorize(HttpMethod.PUT, "/specified_method", denyAll)
}
} With this spec, even though Additionally, if we change the spec for I think this is the behaviour of |
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.
Thanks for the updates @adamu.
The PUT behaviour that you mentioned occurs because the request does not include a CSRF token.
I have added an inline comment showing how to add the CSRF token.
One more note about the commits, please add Fixes: gh-8307
to the final commit.
This will associate the commit with the reported issue and also close the issue when the commit is merged.
See the contributing guidelines for more details
...src/test/kotlin/org/springframework/security/config/web/servlet/AuthorizeRequestsDslTests.kt
Outdated
Show resolved
Hide resolved
...src/test/kotlin/org/springframework/security/config/web/servlet/AuthorizeRequestsDslTests.kt
Outdated
Show resolved
Hide resolved
@eleftherias I have made the following changes:
|
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.
Thanks @adamu! I have left some more comments inline.
...src/test/kotlin/org/springframework/security/config/web/servlet/AuthorizeRequestsDslTests.kt
Outdated
Show resolved
Hide resolved
config/src/main/kotlin/org/springframework/security/config/web/servlet/AuthorizeRequestsDsl.kt
Show resolved
Hide resolved
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.
Thank you for all your work @adamu.
I have one more comment and then we should be ready to merge.
config/src/main/kotlin/org/springframework/security/config/web/servlet/AuthorizeRequestsDsl.kt
Outdated
Show resolved
Hide resolved
Thanks again @adamu! |
Attempted an implementation for #8307, which adds an implementation of
authorize()
forAuthorizeRequestsDsl
, so that we can write code like this: