How to implement spring security connecting with database
java-techie-jt / spring-security-jpa Goto Github PK
View Code? Open in Web Editor NEWHow to implement spring security connecting with database
How to implement spring security connecting with database
Hello,
I am getting a HTTP 403 when trying to add a new user after adding the url authorization rules. I have configured it the same as you mentioned in the youtube video and in this repository. Can you please let me know what could be the issue. I am attaching the code I am using as well.
thank for video .
I have implemented with spring 5.
return user.getRoles().stream().map(role -> new SimpleGrantedAuthority(""+role))
.collect(Collectors.toList());
the hight light work for me. why not ROLE_ADMIN or ROLE_USER
@PreAuthorize("hasAnyRole('ADMIN')") not working
I Have checked your code an unable to figure out, how you have set userDetails object to user object in "CustomUserDetailsService" class . Since there is no such "setUser"method defined in "CustomUserDetails" class.
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
http.authorizeRequests()
.antMatchers("/rest/**").authenticated()
.anyRequest().permitAll()
.and()
.authorizeRequests()
.antMatchers("/secure/**").authenticated()
.anyRequest().hasAnyRole("ADMIN")
.and()
.formLogin().permitAll();
}
@basahota Above is my configure overriden methd.
Still I am getting below mentioned error:
Can't configure antMatchers after anyRequest.
Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.