Notice: This message was sent from outside the University of Victoria email system. Please be cautious with links and sensitive information.
Hello,I have configured CAS in my Spring boot app and when I log in it render to 404 not found with the Service Ticket.Attached is the error image that i got.
ThanksSagar
--
--
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
---
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/05f195cffc9329228b4705f81da7e13f4037c9e8.camel%40uvic.ca.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/e563cb5582248e3b61299aaf01998f5ad03367e9.camel%40uvic.ca.
package com.mynw.sso.Controller;
import com.mynw.sso.CASConfig;
import org.jasig.cas.client.authentication.AttributePrincipal;
import org.jasig.cas.client.validation.Assertion;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.cas.authentication.CasAuthenticationToken;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import java.sql.SQLOutput;
import java.util.logging.Logger;
@Controller
public class SSOController {
@GetMapping("/")
public String index(Model model){
SecurityContext ctx= SecurityContextHolder.getContext();
AnonymousAuthenticationToken aat = (AnonymousAuthenticationToken) ctx.getAuthentication();
System.out.println("The token is " + aat);
model.addAttribute("UserName", aat.toString());
return "index";
}
}
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/07f16efd28acdce013b788b077df0565efd9c4df.camel%40uvic.ca.
Notice: This message was sent from outside the University of Victoria email system. Please be cautious with links and sensitive information.
Hello Ray,
2020-11-05 15:51:21.877 DEBUG 13867 --- [https-jsse-nio-8443-exec-3] o.s.s.cas.web.CasAuthenticationFilter : serviceTicketRequest = false 2020-11-05 15:51:21.877 DEBUG 13867 --- [https-jsse-nio-8443-exec-3] o.s.s.cas.web.CasAuthenticationFilter : proxyReceptorConfigured = false 2020-11-05 15:51:21.877 DEBUG 13867 --- [https-jsse-nio-8443-exec-3] o.s.s.cas.web.CasAuthenticationFilter : proxyReceptorRequest = false 2020-11-05 15:51:21.877 DEBUG 13867 --- [https-jsse-nio-8443-exec-3] o.s.s.cas.web.CasAuthenticationFilter : proxyTicketRequest = false 2020-11-05 15:51:21.877 DEBUG 13867 --- [https-jsse-nio-8443-exec-3] o.s.s.cas.web.CasAuthenticationFilter : requiresAuthentication = false 2020-11-05 15:51:21.878 DEBUG 13867 --- [https-jsse-nio-8443-exec-3] o.s.s.w.a.AnonymousAuthenticationFilter : Populated SecurityContextHolder with anonymous token: 'org.springframework.security.authentication.AnonymousAuthenticationToken@9972129b: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@0: RemoteIpAddress: 10.2.101.208; SessionId: 46E280D90E89E9935FE52EA62CA29C65; Granted Authorities: ROLE_ANONYMOUS'
Looks like I am authenticated but it redirects too many times.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/6798adce6b2ccbf9fc5cd8a6b57390b19e1adbaf.camel%40uvic.ca.
package com.mynw.sso;
import org.jasig.cas.client.session.SingleSignOutFilter;
import org.jasig.cas.client.validation.Cas30ServiceTicketValidator;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.cas.ServiceProperties;
import org.springframework.security.cas.authentication.CasAssertionAuthenticationToken;
import org.springframework.security.cas.authentication.CasAuthenticationProvider;
import org.springframework.security.cas.web.CasAuthenticationEntryPoint;
import org.springframework.security.cas.web.CasAuthenticationFilter;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.AuthenticationUserDetailsService;
import org.springframework.security.web.authentication.logout.LogoutFilter;
import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
import org.springframework.security.web.authentication.session.SessionFixationProtectionStrategy;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import java.util.*;
@Configuration
@EnableWebSecurity
public class WebCASSecurity extends WebSecurityConfigurerAdapter {
@Value("${cas.service.login}")
String CAS_URL_LOGIN;
@Value("${cas.service.logout}")
String CAS_URL_LOGOUT;
@Value("${cas.url.prefix}")
String CAS_URL_PREFIX;
@Value("${cas.ticket.validate.url}")
String CAS_VALIDATE_URL;
@Value("${app.service.security}")
String CAS_SERVICE_URL;
@Value("${app.service.home}")
String APP_SERVICE_HOME;
// @Value("${app.admin.userName:admin}")
// String APP_ADMIN_USER_NAME;
// @Bean
// public Set<String> adminList() {
// Set<String> admins = new HashSet<String>();
// admins.add(APP_ADMIN_USER_NAME);
// return admins;
// }
@Override
protected void configure(HttpSecurity http) throws Exception {
http.exceptionHandling()
.authenticationEntryPoint(casAuthenticationEntryPoint()).and().addFilter(casAuthenticationFilter())
// .addFilterBefore(singleSignOutFilter(), CasAuthenticationFilter.class)
.addFilterBefore(requestCasGlobalLogoutFilter(), LogoutFilter.class)
.authorizeRequests()
.antMatchers("/**")
.access("hasRole('ROLE_ANONYMOUS')");
}
@Bean
public ServiceProperties serviceProperties() {
ServiceProperties sp = new ServiceProperties();
sp.setService(CAS_SERVICE_URL);
sp.setSendRenew(false);
return sp;
}
@Bean
public CasAuthenticationProvider casAuthenticationProvider() {
CasAuthenticationProvider casAuthenticationProvider = new CasAuthenticationProvider();
casAuthenticationProvider.setAuthenticationUserDetailsService(customUserDetailsService());
casAuthenticationProvider.setServiceProperties(serviceProperties());
casAuthenticationProvider.setTicketValidator(Cas30ServiceTicketValidator());
casAuthenticationProvider.setKey("an_id_for_this_auth_provider_only");
return casAuthenticationProvider;
}
@Bean
public AuthenticationUserDetailsService<CasAssertionAuthenticationToken> customUserDetailsService() {
return new CustomUserDetailsService();
}
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(casAuthenticationProvider());
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/fonts/**").antMatchers("/images/**").antMatchers("/scripts/**").antMatchers("/styles/**")
.antMatchers("/views/**").antMatchers("/i18n/**").antMatchers("/webjars/**");
}
@Bean
public SessionAuthenticationStrategy sessionStrategy() {
SessionAuthenticationStrategy sessionStrategy = new SessionFixationProtectionStrategy();
return sessionStrategy;
}
@Bean
public Cas30ServiceTicketValidator Cas30ServiceTicketValidator() {
return new Cas30ServiceTicketValidator(CAS_VALIDATE_URL);
}
public CasAuthenticationEntryPoint casAuthenticationEntryPoint() {
CasAuthenticationEntryPoint casAuthenticationEntryPoint = new CasAuthenticationEntryPoint();
casAuthenticationEntryPoint.setLoginUrl(CAS_URL_LOGIN);
casAuthenticationEntryPoint.setServiceProperties(serviceProperties());
return casAuthenticationEntryPoint;
}
// public SingleSignOutFilter singleSignOutFilter() {
// SingleSignOutFilter singleSignOutFilter = new SingleSignOutFilter();
// singleSignOutFilter.setCasServerUrlPrefix("https://nwmsueist01.nwmissouri.edu:9443/cas");
// return singleSignOutFilter;
// }
@Bean
public LogoutFilter requestCasGlobalLogoutFilter() {
LogoutFilter logoutFilter = new LogoutFilter(
CAS_URL_LOGOUT + "?service=" + APP_SERVICE_HOME,
new SecurityContextLogoutHandler());
logoutFilter.setLogoutRequestMatcher(new AntPathRequestMatcher("/logout", "GET"));
return logoutFilter;
}
@Bean
public CasAuthenticationFilter casAuthenticationFilter() throws Exception {
CasAuthenticationFilter casAuthenticationFilter = new CasAuthenticationFilter();
casAuthenticationFilter.setAuthenticationManager(authenticationManager());
casAuthenticationFilter.setSessionAuthenticationStrategy(sessionStrategy());
return casAuthenticationFilter;
}
}
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/7d19e9528aa4d766347a5623bd4b6aeed86d7697.camel%40uvic.ca.
Notice: This message was sent from outside the University of Victoria email system. Please be cautious with links and sensitive information.
Hello Ray,