go-cas / cas

Golang CAS Client package
MIT License
223 stars 96 forks source link

AuthenticationDate parse error #19

Open helphi opened 6 years ago

helphi commented 6 years ago

CAS3.0 server return AuthenticationDate with ZonedDateTime src, but go-cas parse it with time.Time, so i get the error bellow:

parsing time "2018-06-21T14:44:52.715+08:00[Asia/Shanghai]": extra text: [Asia/Shanghai]

the response is:

curl "http://cas.example.com/p3/serviceValidate?service=http://localhost:9000&ticket=ST-2344-9oiwc7g9_xg5HBxx3T371X4ARLI-db796d3ad01b"

<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
    <cas:authenticationSuccess>
        <cas:user>helphi</cas:user>
        <cas:attributes>
            <cas:credentialType>RememberMeUsernamePasswordCredential</cas:credentialType>
            <cas:isFromNewLogin>true</cas:isFromNewLogin>
            <cas:mail>helphi@example.com</cas:mail>
            <cas:authenticationDate>2018-06-21T13:43:07.597+08:00[Asia/Shanghai]</cas:authenticationDate>
            <cas:authenticationMethod>LdapAuthenticationHandler</cas:authenticationMethod>
            <cas:successfulAuthenticationHandlers>LdapAuthenticationHandler</cas:successfulAuthenticationHandlers>
            <cas:longTermAuthenticationRequestTokenUsed>true</cas:longTermAuthenticationRequestTokenUsed>
            <cas:sn>helphi.he</cas:sn>
            </cas:attributes>
    </cas:authenticationSuccess>
</cas:serviceResponse>
geoffgarside commented 6 years ago

Based on the CAS 3.0 spec that form of cas:authenticationDate isn't valid for the XML Schema xs:dateTime type.

helphi commented 6 years ago

Based on the CAS 3.0 spec, cas server use ZonedDateTime to process xs:dateTime and go-cas use time.Time to process xs:dateTime, but ZonedDateTime of java is not compatible with time.Time of golang.

geoffgarside commented 6 years ago

It doesn't look like ZonedDateTime is compatible with xs:dateTime, so while it may be able to parse it in Java it doesn't look like the generation of the authenticationDate in the apero CAS server is valid according to the specification.

helphi commented 6 years ago

But CAS server and the cas-java-client implements xs:dateTime with ZonedDateTime now, and we can't parse it with go-cas.

l1905 commented 4 years ago

my result is same, it need to compatible, or cas 3.0 will not work