Posts

Showing posts with the label Spring Security

@EnableResourceServer Vs (@EnableOAuth2Sso and @EnableOAuth2Client)

OAuth defines four roles: resource owner An entity capable of granting access to a protected resource. When the resource owner is a person, it is referred to as an end-user. resource server The server hosting the protected resources, capable of accepting and responding to protected resource requests using access tokens. client An application making protected resource requests on behalf of the resource owner and with its authorization. The term "client" does not imply any particular implementation characteristics (e.g., whether the application executes on a server, a desktop, or other devices). authorization server The server issuing access tokens to the client after successfully authenticating the resource owner and obtaining authorization. @EnableResourceServer  annotation means that your service (in terms of OAuth 2.0 - Resource Server) expects an access token in order to process...

H2-Console is not showing in browser

Image
If you have override configure method of Spring Security and you want to use console of h2 database in browser, and after connect h2-console showing loading error as shown in below image. Then you have to add following line in your overridden configure method. @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter {    Logger logger = LoggerFactory.getLogger(SecurityConfig. class );       //......            @Override    protected void configure(HttpSecurity http) throws Exception {      http.authorizeRequests().antMatchers( "/" ).permitAll();      http.authorizeRequests().antMatchers( "/imgs/**" ).permitAll();      http.authorizeRequests().antMatchers( "/admin/**" ).hasRole( "ADMIN" );      http.authorizeRequests().antMatchers( "/**" ).hasRole( "USER" ).and().formLogin(); ...