Browse Source

Un-hardcode WebSecurityConfig authorities; add commenting

Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.3-alpha
Pekka Helenius 4 years ago
parent
commit
dbf1af523c
1 changed files with 7 additions and 2 deletions
  1. +7
    -2
      bookstore/src/main/java/com/fjordtek/bookstore/config/WebSecurityConfig.java

+ 7
- 2
bookstore/src/main/java/com/fjordtek/bookstore/config/WebSecurityConfig.java View File

@ -83,7 +83,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatcher(env.getProperty("spring.data.rest.base-path") + "/**") .antMatcher(env.getProperty("spring.data.rest.base-path") + "/**")
.authorizeRequests( .authorizeRequests(
authorize -> authorize authorize -> authorize
.anyRequest().hasAuthority("ADMIN")
.anyRequest().hasAuthority(env.getProperty("auth.authority.admin"))
) )
.httpBasic() .httpBasic()
.and() .and()
@ -106,6 +106,11 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override @Override
protected void configure(HttpSecurity httpSecurity) throws Exception { protected void configure(HttpSecurity httpSecurity) throws Exception {
/*
* Explicitly Permit access to specific end points.
* Basic norm is: if the end point access is not permitted here,
* public access to it is denied by default.
*/
httpSecurity httpSecurity
.authorizeRequests() .authorizeRequests()
.antMatchers( .antMatchers(
@ -119,7 +124,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
// "/favicon.ico", // "/favicon.ico",
).permitAll() ).permitAll()
.antMatchers(env.getProperty("page.url.apiref") + "/**") .antMatchers(env.getProperty("page.url.apiref") + "/**")
.hasAuthority("ADMIN")
.hasAuthority(env.getProperty("auth.authority.admin"))
.anyRequest() .anyRequest()
.authenticated() .authenticated()
.and() .and()


Loading…
Cancel
Save