Как получить пользователя CAS в Grails 3.3.x? - PullRequest
0 голосов
/ 28 августа 2018

Мне тяжело изучать безопасность Spring и Grails.

У меня есть приложение, которое я хочу иметь возможность аутентифицироваться с помощью testlogin.ua.edu / cas / login . Я ДУМАЛ, что использовал плагин Spring Security, но этот мерзавец говорит: « Java Apereo CAS Client ». В конечном счете я хотел бы, чтобы решение EASY получило доступ к имени пользователя, которое оно возвращает (gjbowen), и использовало его для дополнительных проверок и т. Д. В контроллере. Все остальные вопросы, связанные с этим, которые я погуглил за последние несколько недель, либо устарели, либо не дали мне удачи. Если бы кто-нибудь мог дать понимание и сделать его безошибочным для меня, это было бы очень признательно !!

Возвращает учетные данные из Cas20ServiceTicketValidator на основе входа в систему, содержащего:

o.j.c.c.v.Cas20ServiceTicketValidator    : Server response: <cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
    <cas:authenticationSuccess>
        <cas:user>gjbowen</cas:user>
        </cas:authenticationSuccess>
</cas:serviceResponse>

в моем билде. Gradle

compile "org.grails.plugins:spring-security-cas:3.1.0"
compile "org.grails.plugins:spring-security-core:3.2.3"

application.yml:

environments:
    development:
        grails:
            plugin:
                springsecurity:        
                    userLookup.userDomainClassName : fzbidcm.User
                    userLookup.authorityJoinClassName : fzbidcm.UserRole
                    userLookup.authority.className: fzbidcm.Role
                    cas:
                        serverUrlPrefix: https://testlogin.ua.edu/cas
                        loginUri: /login
                        key: myApp
                        serviceUrl: http://localhost:8080/login/cas
                        useSingleSignout: false

дополнительный вход

DEBUG ---  tContextHolderExceptionTranslationFilter : Calling Authentication entry point.
DEBUG ---  w.c.HttpSessionSecurityContextRepository : SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
DEBUG ---  s.s.w.c.SecurityContextPersistenceFilter : SecurityContextHolder now cleared, as request processing completed
DEBUG ---  o.g.w.s.mvc.GrailsWebRequestFilter       : Bound Grails request context to thread: org.apache.catalina.connector.RequestFacade@2d0a86ce
DEBUG ---  o.s.s.w.u.matcher.AntPathRequestMatcher  : Request '/user/login' matched by universal pattern '/**'
DEBUG ---  o.s.security.web.FilterChainProxy        : /user/login?ticket=ST-2426-3GDsZ2cVi1udFYgloDMfCgsei7U-bnrbeis-test at position 1 of 11 in additional filter chain; firing Filter: 'SecurityRequestHolderFilter'
DEBUG ---  o.s.security.web.FilterChainProxy        : /user/login?ticket=ST-2426-3GDsZ2cVi1udFYgloDMfCgsei7U-bnrbeis-test at position 2 of 11 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
DEBUG ---  w.c.HttpSessionSecurityContextRepository : HttpSession returned null object for SPRING_SECURITY_CONTEXT
DEBUG ---  w.c.HttpSessionSecurityContextRepository : No SecurityContext was available from the HttpSession: org.apache.catalina.session.StandardSessionFacade@5def7c2c. A new one will be created.
DEBUG ---  o.s.security.web.FilterChainProxy        : /user/login?ticket=ST-2426-3GDsZ2cVi1udFYgloDMfCgsei7U-bnrbeis-test at position 3 of 11 in additional filter chain; firing Filter: 'MutableLogoutFilter'
DEBUG ---  o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/user/login'; against '/logoff'
DEBUG ---  o.s.security.web.FilterChainProxy        : /user/login?ticket=ST-2426-3GDsZ2cVi1udFYgloDMfCgsei7U-bnrbeis-test at position 4 of 11 in additional filter chain; firing Filter: 'CasAuthenticationFilter'
DEBUG ---  o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/user/login'; against '/user/login'
DEBUG ---  o.s.s.cas.web.CasAuthenticationFilter    : serviceTicketRequest = true
DEBUG ---  o.s.s.cas.web.CasAuthenticationFilter    : requiresAuthentication = true
DEBUG ---  o.s.s.cas.web.CasAuthenticationFilter    : Request is to process authentication
DEBUG ---  o.s.s.cas.web.CasAuthenticationFilter    : proxyReceptorConfigured = true
DEBUG ---  o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/user/login'; against '/**null'
DEBUG ---  o.s.s.cas.web.CasAuthenticationFilter    : proxyReceptorRequest = false
DEBUG ---  o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/user/login'; against '/user/login'
DEBUG ---  o.s.s.cas.web.CasAuthenticationFilter    : serviceTicketRequest = true
DEBUG ---  o.s.s.authentication.ProviderManager     : Authentication attempt using org.springframework.security.cas.authentication.CasAuthenticationProvider
DEBUG ---  o.s.s.c.a.CasAuthenticationProvider      : serviceUrl = http://localhost:8080/user/login
DEBUG ---  o.j.c.c.v.Cas20ServiceTicketValidator    : Placing URL parameters in map.
DEBUG ---  o.j.c.c.v.Cas20ServiceTicketValidator    : Calling template URL attribute map.
DEBUG ---  o.j.c.c.v.Cas20ServiceTicketValidator    : Loading custom parameters from configuration.
DEBUG ---  o.j.c.c.v.Cas20ServiceTicketValidator    : Constructing validation url: https://testlogin.ua.edu/cas/serviceValidate?ticket=ST-2426-3GDsZ2cVi1udFYgloDMfCgsei7U-bnrbeis-test&service=http%3A%2F%2Flocalhost%3A8080%2Fuser%2Flogin
DEBUG ---  o.j.c.c.v.Cas20ServiceTicketValidator    : Retrieving response from server.
DEBUG ---  o.j.c.c.v.Cas20ServiceTicketValidator    : Server response: <cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
    <cas:authenticationSuccess>
        <cas:user>gjbowen</cas:user>
        </cas:authenticationSuccess>
</cas:serviceResponse>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...