Cas server - 5.2.5 and Rest Authentication support

729 views
Skip to first unread message

Raghavan TV

unread,
Jun 15, 2018, 1:33:54 PM6/15/18
to CAS Community
Hi,

Am testing CAS against rest-authentication method. 

But am always receiving an error in the log that says
[1;31m2018-06-15 22:59:38,794 ERROR [org.apereo.cas.authentication.PolicyBasedAuthenticationManager] - <[restauth]: [JSON parse error: Missing type id when trying to resolve subtype of [simple type, class org.apereo.cas.authentication.principal.SimplePrincipal]: missing type id property '@class'; nested exception is com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Missing type id when trying to resolve subtype of [simple type, class org.apereo.cas.authentication.principal.SimplePrincipal]: missing type id property '@class'
 at
[Source: (PushbackInputStream); line: 1, column: 54] / Missing type id when trying to resolve subtype of [simple type, class org.apereo.cas.authentication.principal.SimplePrincipal]: missing type id property '@class'
 at
[Source: (PushbackInputStream); line: 1, column: 54]]> [m
[1;31m2018-06-15 22:59:38,795 ERROR [org.apereo.cas.authentication.PolicyBasedAuthenticationManager] - <Authentication has failed. Credentials may be incorrect or CAS cannot find authentication handler that supports [admin] of type [UsernamePasswordCredential]. Examine the configuration to ensure a method of authentication is defined and analyze CAS logs at DEBUG level to trace the authentication event.> [m



Am I missing some configuration related to Policy ?


Environment
Windows 7
JDK: 8
Tomcat: 9.0.8



----------------
Steps followed
----------------
1) Edited the pom.xml to add the rest-authentication overlay
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-rest-authentication</artifactId>
<version>${cas.version}</version>
</dependency>
2) Deployed a new REST (mock) service

Note:
Checked the logs and the request from CAS server is fine and the response is also a HTTP-200 with following response
{"@c":".SimplePrincipal","attributes":{},"id":"adminuser"}


3) Edited application.properties with following configured

cas.authn.accept.users=
logging
.level.org.apereo=TRACE
logging
.level.org.jasig=TRACE
logging
.level.org.apache=DEBUG

cas
.authn.rest.uri=http://localhost:9909/idp/authenticate
cas
.authn.rest.name=restauth
cas
.authn.rest.passwordEncoder.type=NONE



Chia-Ying (David) Yang

unread,
Jun 15, 2018, 1:37:54 PM6/15/18
to cas-...@apereo.org
I ran into that the other day and got it working by changing it to "@class": "org.apereo.cas.authentication.principal.SimplePrincipal".

David
--
- 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/f54a1513-f86b-41e1-92a5-ea99092d50d0%40apereo.org.

Raghavan TV

unread,
Jun 15, 2018, 2:04:28 PM6/15/18
to CAS Community
Hi David

Yes. That solved the issue. 
Many thanks

Raghav

dg

unread,
Apr 15, 2020, 11:34:14 AM4/15/20
to CAS Community
hey, i got same issue. actually i dont understand solution. can you provide more information?

15 Haziran 2018 Cuma 20:33:54 UTC+3 tarihinde Raghavan TV yazdı:

dg

unread,
Apr 15, 2020, 12:06:04 PM4/15/20
to CAS Community
i return id and attributes from rest endpoint as response. 

my cas config

cas.authn.rest.uri=http://localhost:8082/validate
cas.authn.rest.name=restauth
cas.authn.rest.charset=UTF-8
cas.authn.rest.passwordEncoder.type=NONE

here is the log. "dg" value is returned from endpoint. so successful authentication at rest side. but error in cas side.

2020-04-15 18:57:46,630 ERROR [org.apereo.cas.authentication.PolicyBasedAuthenticationManager] - <Authentication has failed. 
Credentials may be incorrect or CAS cannot find authentication handler that supports 
[UsernamePasswordCredential(username=dg, source=null, customFields={})] of type [UsernamePasswordCredential]. 
Examine the configuration to ensure a method of authentication is defined and analyze CAS logs at DEBUG level to trace the authentication event.>

2020-04-15 18:57:46,630 ERROR [org.apereo.cas.authentication.PolicyBasedAuthenticationManager] - <[restauth]: [Error while extracting response for type 
[class org.apereo.cas.authentication.principal.SimplePrincipal] and content type [application/json]; 
nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Missing type id when trying to resolve subtype of 
[simple type, class org.apereo.cas.authentication.principal.SimplePrincipal]: missing type id property '@class'; nested exception is com.fasterxml.jackson.databind.exc.InvalidTypeIdException: 
Missing type id when trying to resolve subtype of [simple type, class org.apereo.cas.authentication.principal.SimplePrincipal]: missing type id property '@class'
 at [Source: (PushbackInputStream); line: 1, column: 27] / JSON parse error: Missing type id when trying to resolve subtype of [simple type, class org.apereo.cas.authentication.principal.SimplePrincipal]: 
missing type id property '@class'; nested exception is com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Missing type id when trying to resolve subtype of [simple type, class org.apereo.cas.authentication.principal.SimplePrincipal]: 
missing type id property '@class'
 at [Source: (PushbackInputStream); line: 1, column: 27]]>
2020-04-15 18:57:46,631 INFO [org.apereo.cas.authentication.PolicyBasedAuthenticationManager] - <[Static Credentials] exception details: [dg not found in backing map.].>

dg

unread,
Apr 16, 2020, 4:35:17 AM4/16/20
to CAS Community
okey. i found the solution. 

in rest response, i provided "id" and "attributes". but when i add "@class" variable, it works.

@Data
private static class ResponseDTO {
@JsonProperty("@class")
private String clazz;
private String id;
private final Map<String, Object> attributes;
ResponseDTO(String id) {
this.id = id;
clazz = "org.apereo.cas.authentication.principal.SimplePrincipal";
attributes = new HashMap<>();
}
}
Reply all
Reply to author
Forward
0 new messages