Re: [cas-user] cas-overlay Build Failure on CustomLDAPAuthenticationHandler

119 views
Skip to first unread message

Ray Bon

unread,
May 24, 2019, 11:50:32 AM5/24/19
to cas-...@apereo.org
Rana,


You might find it easier to build up your custom class instead of copying an existing class and removing the items you do not want. And if you find that you need a lot of what is provided in an existing class, extend that class and override only the parts you need to.

Ray



On Fri, 2019-05-24 at 04:59 -0700, Rana Prathap B wrote:
Hi All,

I have a requirement to process the auth response before I give it to client.  

i.e Post to successful authentication I would like to make a REST call to validate the user against 3rd party and return the AuthResposne. 


As part of this I have written a new CustomAuthHandlerConfig.java which is as similar as LdapAuthenticationConfiguration in CAS. 

Getting below errors during cas-overlay build. 

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/username/cas-workspace/cas-overlay-template/src/main/java/com/pramati/cas/config/CustomAuthHandlerConfig.java:[22,45] package org.apereo.cas.authentication.support does not exist
[ERROR] /home/username/cas-workspace/cas-overlay-template/src/main/java/com/pramati/cas/config/CustomAuthHandlerConfig.java:[23,45] package org.apereo.cas.authentication.support does not exist
[ERROR] /home/username/cas-workspace/cas-overlay-template/src/main/java/com/pramati/cas/config/CustomAuthHandlerConfig.java:[24,45] package org.apereo.cas.authentication.support does not exist
[ERROR] /home/username/cas-workspace/cas-overlay-template/src/main/java/com/pramati/cas/config/CustomAuthHandlerConfig.java:[33,27] package org.apereo.cas.util does not exist
[ERROR] /home/username/cas-workspace/cas-overlay-template/src/main/java/com/pramati/cas/config/CustomAuthHandlerConfig.java:[34,27] package org.apereo.cas.util does not exist

Added Dependency as:

<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-core-authentication-api</artifactId>
<version>${cas.version}</version>
</dependency>
 

Attached related files for the same.   

-- 
Ray Bon
Programmer Analyst
Development Services, University Systems

Rana Prathap B

unread,
May 24, 2019, 1:59:06 PM5/24/19
to CAS Community
Thanks Ray, Build was success. 

I am overriding the existing LDAPAuthConfig with CustomLDAPAuthConfig. added the config class name under spring.properties too but the CustomLDAPHandler is not getting registered. Can you please check the attached files and let me know is this the proper way to override the CAS LDAPAuthHandler?

-Rana
CustomAuthHandlerConfig.java
spring.factories
CustomAuthHandler.java

Ray Bon

unread,
May 24, 2019, 6:13:32 PM5/24/19
to cas-...@apereo.org
Rana,

In CustomAuthHandlerConfig, set your value for @Configuration.
Put the spring.factories file with your code. It might work the way you have it with tomcat config but I do not know. See https://github.com/apereo/cas/tree/master/support/cas-server-support-ldap/src/main

Ray

Rana Prathap B

unread,
May 27, 2019, 3:35:49 PM5/27/19
to CAS Community
Hello Ray,

I already have @Configuration("ldapAuthenticationConfiguration") for my CustomAuthHandlerConfig. I am going through https://apereo.github.io/cas/5.3.x/installation/Configuration-Management-Extensions.html#overrides documentation to override existing LDAPAuthHandler provided by CAS.

I observed that my LDAPAuthConfig is getting loaded instead of CustomAuthHandlerConfig. Kindly check the file CustomAuthHandlerConfig.java and suggest how can I proceed.

-Rana

Andy Ng

unread,
May 27, 2019, 6:46:19 PM5/27/19
to CAS Community
Try adding Import(LdapAuthenticationConfiguration.class) at the top of your custom Configuration class.

- Andy

Rana Prathap B

unread,
May 30, 2019, 8:13:53 AM5/30/19
to CAS Community
It did not work :( I suspect my custom configuration not loaded at all. Do I need to mention my custom configuration anywhere other than spring.factories ?

Andy Ng

unread,
May 30, 2019, 8:38:06 AM5/30/19
to CAS Community
Hi Rana,

Hmm very strange indeed, 


> need to mention my custom configuration anywhere other than spring.factories?
No, only in spring.factories is ok, BTW you do not need to include CasEmbeddedContainerTomcatConfiguration and CasEmbeddedContainerTomcatFiltersConfiguration in your spring.factories, although it shouldn't be what cause your problem

a few more things you can check to see if will resolve this:
- Can you show me the layout of the few files you given? Sometime the config file is valid, but put in the wrong spot
- In your CustomAuthConfiguration file, can you change the line from @Configuration("ldapAuthenticationConfiguration") to @Configuration("customAuthConfiguration"). Should change the name of the string to the same as your class
- Try not to use ConditionalOnMissingBean inside your own function, the notation is used for allowing your to more easily override the function, so you should remove that notation inside your code
- And... did you add any configuration inside cas.properties or other properties / yml files? Because looking at your code, it would only work if you have setup some config already, can you show us your config file (i.e. cas.properties or equilalent)

BTW, I highly suggest your CustomAuthHandlerConfig class extends from LdapAuthenticationConfiguration, that way you didn't have to copy all the function in your own implementation.

See if the above helps you!

Cheers!
- Andy

Reply all
Reply to author
Forward
0 new messages