Comments (5)
import com.kakawait.spring.boot.security.cas.CasSecurityConfigurerAdapter;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled = true, proxyTargetClass = true)
public class SecurityConfiguration extends CasSecurityConfigurerAdapter {
}
Adding that class solved it for me.
However i am now noticing that my spring security context does not have any roles (apart from ROLE_USER) in the granted authorities for my session. Any idea what i am doing wrong?
EDIT:
Okay. so it turns out i will have to get them roles from the Active directory. I am currently working to get that sorted. Will post it here once sorted. Any help to speed up the process is however appreciated.
from cas-security-spring-boot-starter.
@Override
protected UserDetails loadUserDetails(Assertion assertion) {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
List<GrantedAuthority> grantedAuthorities = getRoles(assertion.getPrincipal().getName());
/* final List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>();
grantedAuthorities.add(new SimpleGrantedAuthority("ROLE_ADMIN"));
grantedAuthorities.add(new SimpleGrantedAuthority("ROLE_USER"));*/
return new User(assertion.getPrincipal().getName(),"[PROTECTED]", true, true, true, true, grantedAuthorities);
}
Okay this is a very weird one. I have worked out to get the Roles from ldap and my method "getRoles()" is fetching the correct roles. Now the problem is that my @secured annotation is not working for any of the roles that i am getting back.
However if i manually add ROLE_USER to the list and then grant ROLE_USER access to the request mapping it works. But it only works for the ROLE_USER
I have checked my session on tomcat and my SPRING_SECURITY_CONTEXT attribute shows all the added roles in the list of Granted Authorities.
from cas-security-spring-boot-starter.
Okay got it all to work. Turns out the application relies on ROLE_USER to be there to access all controllers
from cas-security-spring-boot-starter.
Which version are you using? Latest 0.8.0 or you build the 1.0.0-SNAPSHOT?
from cas-security-spring-boot-starter.
Using 0.8.0. Sorry for a late reply.
from cas-security-spring-boot-starter.
Related Issues (20)
- Securing CORS RestAPI HOT 1
- Where is 1.0.0-beta-1 built from? HOT 6
- Cannot get targetUrl HOT 5
- Does it support set `ignorePattern` HOT 4
- Integration tests
- Invalid custom permission validation HOT 5
- Support for Saml11TicketValidator HOT 1
- Endpoint which authenticate from CAS Server HOT 1
- Whether it is suitable for front-end projects HOT 4
- Configuration question HOT 1
- Proxy Ticket Validator Configuration Property HOT 1
- Replace PostConstruct
- Fix JDK11 build
- Compilation error java-cas-client 3.6.1 HOT 1
- [Question] How to extract attributes from XML document return by ticket validation? HOT 1
- CAS logout custom configuration logout success url ? HOT 1
- CAS Proxy Authentication HOT 6
- Problem with Logout HOT 3
- Use springboot 2.7.0+ with SecurityFilterChain instead of deprecated WebSecurityConfigurerAdapter HOT 1
- When will it be possible to use this library with spring boot 3?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cas-security-spring-boot-starter.