I have a custom AuthenticationHandler because my users get authenticated 
against a BPM engine. This is working fine. Now I also have to retrieve the 
roles. I can do this also in the authentication handler. However, I don't 
see the 'roles' attribute in the validation response. XML.Here is the 
authentication handler:

protected HandlerResult 
authenticateUsernamePasswordInternal(UsernamePasswordCredential 
transformedCredential, String originalPassword)
            throws GeneralSecurityException, PreventedException {

        logger.debug("Logging in into the Bonita Engine.");

        // get the username/password
        final String username = transformedCredential.getUsername();
        final String password = transformedCredential.getPassword();

        // check the login
        try {
            List<String> authorities = login(username, password);

            // construct attributes
            Map<String, Object> attributes = new HashMap<>();
            attributes.put("roles", authorities);
            // attributes.put("roles", authorities.toArray(new 
String[authorities.size()]));

            // return the handler result
            return createHandlerResult(transformedCredential, 
this.principalFactory.createPrincipal(username, attributes), null);
        } catch (Exception e) {
            logger.error("Error logging in: {}", e.getMessage());
            logger.debug("Exception:", e);
        }

        // throw the exception if the login has not been valid.
        throw new FailedLoginException(String.format("Could not 
authenticate the user '%s'", username));
    }

I have tried every cas.authn.attributeRepository.merger , but without 
success. Interestingly, if I name the attribute with a different name (e.g. 
"asdasd"), I can see the roles there.

Another thing is also, that I am using the OAuth server support with the 
resource owner password schema. I can successfully validate but in the 
response I am getting only the AT, RT, token_type and expiration. But no 
other attributes. I would like to save the one another request to the 
/p3/serviceValidate. Is this somehow possible to configure. I am using CAS 
5.1.

-- 
- CAS gitter chatroom: https://gitter.im/apereo/cas
- CAS mailing list guidelines: https://apereo.github.io/cas/Mailing-Lists.html
- CAS documentation website: https://apereo.github.io/cas
- CAS project website: https://github.com/apereo/cas
--- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/462b3357-59ab-4c2e-ae44-68ee6282e3f2%40apereo.org.

Reply via email to