casinthecloud / cas-pac4j-oauth-demo

CAS server demo to test the authentication delegation
https://www.casinthecloud.com
76 stars 62 forks source link

CasOAuthWrapper Login can not redirect to client , cas 4.2.x #32

Closed qifali closed 8 years ago

qifali commented 8 years ago

I'm Using cas-pac4j-oauth-demo 4.2.x branche and face a problem, when I choice CasOAuthWrapper and login on cas2, then login success, but it still in cas2 login success page and not redirect to the cas login success page, and i see the log output below:

2016-07-25 22:57:27,243 INFO [org.jasig.cas.authentication.PolicyBasedAuthenticationManager] - 2016-07-25 22:57:27,243 INFO [org.jasig.cas.authentication.PolicyBasedAuthenticationManager] - <Authenticated jleleu with credentials [jleleu].> 2016-07-25 22:57:27,244 INFO [org.jasig.inspektr.audit.support.Slf4jLoggingAuditTrailManager] <Audit trail record BEGIN WHO: jleleu WHAT: Supplied credentials: [jleleu] ACTION: AUTHENTICATION_SUCCESS APPLICATION: CAS WHEN: Mon Jul 25 22:57:27 CST 2016 CLIENT IP ADDRESS: 0:0:0:0:0:0:0:1 SERVER IP ADDRESS: 0:0:0:0:0:0:0:1

2016-07-25 22:57:27,246 INFO [org.jasig.inspektr.audit.support.Slf4jLoggingAuditTrailManager] <Audit trail record BEGIN WHO: audit:unknown WHAT: TGT-**Aau2tMLp9I-cas01.example.org ACTION: TICKET_GRANTING_TICKET_CREATED APPLICATION: CAS WHEN: Mon Jul 25 22:57:27 CST 2016 CLIENT IP ADDRESS: 0:0:0:0:0:0:0:1 SERVER IP ADDRESS: 0:0:0:0:0:0:0:1

I see use cas login works well ! But I need to support oauth ... Help, pls!

qifali commented 8 years ago

And the same as login through SAML

qifali commented 8 years ago

I fixed it by add follow codes in web.xml:

    <servlet-mapping>
        <servlet-name>cas</servlet-name>
        <url-pattern>/oauth2.0/*</url-pattern>
    </servlet-mapping>

in cas-pac4j-oauth-demo it doesn't include web.xml. Am I fixed the right way?

leleuj commented 8 years ago

In 4.2, the controller should be registered automatically thanks to: https://github.com/apereo/cas/blob/4.2.x/cas-server-support-oauth/src/main/java/org/jasig/cas/support/oauth/OAuthServletContextListener.java

Did you test it via the Jetty Maven plugin or via a standard Tomcat (for example) installation?

qifali commented 8 years ago

thx @leleuj

I clone cas-pac4j-oauth-demo 4.2.x branche and open in intellij, use jdk 1.8 test via Jetty Maven plugin command : jetty:run, when i access : http://localhost:8080/cas/login and choice login with CasOAuthWrapper, it redirct to http://localhost:8080/cas2/login?client_id=xxx&client_secret=xxx&redirect_uri=xxx (it seems redirct to the wrong url),

then i input my username & password , it login success ,but in cas2 login success page, and the url not change, It seems /oauth2.0/* not registered automatically.

I clone 4.1.x branche, I see when use OauthWrapper link, it will redirect to the login page through url below: http://localhost:8080/cas2/login?service=http%3A%2F%2Flocalhost%3A8080%2Fcas2%2Foauth2.0%2FcallbackAuthorize