Skip to content

Commit

Permalink
Typo: Update authorize-http-requests.adoc
Browse files Browse the repository at this point in the history
'patters' -> 'pattern'
-----
'db' -> "db",
'ADMIN' -> "ADMIN"
They should be string type
-----
There is no semicolon. I added it.
-----
There is no semicolon at the end of the sentence. So I added
  • Loading branch information
boulce committed Feb 7, 2024
1 parent 421bf9e commit a67affb
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void endpointWhenNotUserAuthorityThenForbidden() {
@Test
void anyWhenUnauthenticatedThenUnauthorized() {
this.mvc.perform(get("/any"))
.andExpect(status().isUnauthorized())
.andExpect(status().isUnauthorized());
}
----
======
Expand Down Expand Up @@ -387,7 +387,7 @@ void endpointWhenNotUserAuthorityThenForbidden() {
@Test
void anyWhenUnauthenticatedThenUnauthorized() {
this.mvc.perform(get("/any"))
.andExpect(status().isUnauthorized())
.andExpect(status().isUnauthorized());
}
----
======
Expand Down Expand Up @@ -521,7 +521,7 @@ void getWhenNoReadAuthorityThenForbidden() {
@Test
void postWhenWriteAuthorityThenAuthorized() {
this.mvc.perform(post("/any").with(csrf()))
.andExpect(status().isOk())
.andExpect(status().isOk());
}
@WithMockUser(authorities="read")
Expand Down Expand Up @@ -737,7 +737,7 @@ SecurityFilterChain web(HttpSecurity http) throws Exception {
.dispatcherTypeMatchers(FORWARD, ERROR).permitAll() // <2>
.requestMatchers("/static/**", "/signup", "/about").permitAll() // <3>
.requestMatchers("/admin/**").hasRole("ADMIN") // <4>
.requestMatchers("/db/**").access(allOf(hasAuthority('db'), hasRole('ADMIN'))) // <5>
.requestMatchers("/db/**").access(allOf(hasAuthority("db"), hasRole("ADMIN"))) // <5>
.anyRequest().denyAll() // <6>
);
Expand Down Expand Up @@ -805,7 +805,7 @@ Xml::
</http>
----
======
<1> We specified a URL patters that any user can access.
<1> We specified a URL pattern that any user can access.
Specifically, any user can access a request if the URL starts with "/static/".
<2> Any URL that starts with "/admin/" will be restricted to users who have the role "ROLE_ADMIN".
You will notice that since we are invoking the `hasRole` method we do not need to specify the "ROLE_" prefix.
Expand Down

0 comments on commit a67affb

Please sign in to comment.