-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d211d51
commit d189e00
Showing
11 changed files
with
226 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/node_modules/ | ||
**/*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip | ||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 39 additions & 23 deletions
62
src/main/java/me/sathish/sathishprojectconfigserver/WebSecurityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,54 @@ | ||
package me.sathish.sathishprojectconfigserver; | ||
|
||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | ||
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; | ||
import org.springframework.security.core.userdetails.User; | ||
import org.springframework.security.core.userdetails.UserDetailsService; | ||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||
import org.springframework.security.provisioning.InMemoryUserDetailsManager; | ||
|
||
@Configuration | ||
@EnableWebSecurity(debug = true) | ||
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | ||
final | ||
BasicAuthBean environment; | ||
@EnableMethodSecurity(securedEnabled = true, jsr250Enabled = true) | ||
public class WebSecurityConfig { | ||
final BasicAuthBean environment; | ||
|
||
public WebSecurityConfig(BasicAuthBean environment) { | ||
this.environment = environment; | ||
} | ||
@Value("${spring.security.debug:false}") | ||
boolean securityDebug; | ||
|
||
// | ||
@Override | ||
protected void configure(AuthenticationManagerBuilder auth) throws Exception { | ||
auth.inMemoryAuthentication() | ||
.passwordEncoder(new BCryptPasswordEncoder()) | ||
.withUser(environment.getUsername()) | ||
.password(environment.getPassword()) | ||
.roles("ADMIN") | ||
; | ||
@Bean | ||
public BCryptPasswordEncoder bCryptPasswordEncoder() { | ||
return new BCryptPasswordEncoder(); | ||
} | ||
|
||
@Override | ||
protected void configure(HttpSecurity http) throws Exception { | ||
http.authorizeRequests() | ||
.anyRequest().authenticated() | ||
.and() | ||
.httpBasic(); | ||
@Bean | ||
public UserDetailsService userDetailsService() { | ||
InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager(); | ||
manager.createUser( | ||
User.withUsername(environment.getUsername()) | ||
.password(bCryptPasswordEncoder().encode(environment.getPassword())) | ||
.roles("USER") | ||
.build()); | ||
manager.createUser( | ||
User.withUsername(environment.getUsername() + "Admin") | ||
.password(bCryptPasswordEncoder().encode(environment.getPassword())) | ||
.roles("USER", "ADMIN") | ||
.build()); | ||
return manager; | ||
} | ||
} | ||
|
||
|
||
@Bean | ||
public WebSecurityCustomizer webSecurityCustomizer() { | ||
return web -> | ||
web.debug(securityDebug) | ||
.ignoring() | ||
.requestMatchers("/css/**", "/js/**", "/img/**", "/lib/**", "/favicon.ico"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.