CAS Database Authentication is not working

こ雲淡風輕ζ 提交于 2019-12-23 15:12:17

问题


Continuation of my earlier question. I'm working on CAS 5 to modify according to my needs. With help of CAS tutorial now I've done customized authentication. Now I've added below dependency to pom.xml to connect to database by following link.

<dependency>
    <groupId>org.apereo.cas</groupId>
    <artifactId>cas-server-support-jdbc</artifactId>
    <version>${cas.version}</version>
</dependency>

And added database authentication properties in application.properties

cas.authn.jdbc.query[0].sql=some query
cas.authn.jdbc.query[0].url=jdbc:postgresql://127.0.0.1/dbcas
cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.PostgreSQLDialect
cas.authn.jdbc.query[0].user=readonly
cas.authn.jdbc.query[0].password=readonly
cas.authn.jdbc.query[0].ddlAuto=none
cas.authn.jdbc.query[0].driverClass=org.postgresql.Driver

But it's not working means getting

Type 'org.apereo.cas.configuration.model.support.jdbc.QueryJdbcAuthenticationProperties' has no property 'url'

Am I missing anything here. Any one please help me in this.

Update:

I've checked the source of QueryJdbcAuthenticationProperties

@RequiredProperty
private String sql;

And AbstractJpaProperties

private String dialect;
private String ddlAuto;
@RequiredProperty
private String driverClass;
@RequiredProperty
private String url;
@RequiredProperty
private String user;
@RequiredProperty
private String password;

I found same two classes in cas-server-core-api-configuration-model-5.3.2.jar file and these two are not found in any other package and jar file.

What's the issue here. I'm unable to identified it.

How to know where these properties (cas.authn.jdbc.query) has been defined?

I thought that object has been created w.r.t child class QueryJdbcAuthenticationProperties while defining these database properties.


回答1:


When you look into the classes you describe, i. e. AbstractJpaProperties and QueryJdbcAuthenticationProperties, you will see something like this at their beginning:

// ...
import lombok.Getter;
import lombok.Setter;

// ...
@Getter
@Setter
public abstract class AbstractJpaProperties implements Serializable {

    // ...
    @RequiredProperty
    private String url = "jdbc:hsqldb:mem:cas-hsql-database";

And no getters and setters for the fields. That means that Lombok takes care of generating them at compile time. If you open the class directly from cas-server-core-api-configuration-model-5.3.2.jar, your IDE should show you the getters and setters in the class outline (in the compiled class only).

So maybe you try to build those classes (or the whole CAS?) yourself without having the Lombok library in the build path? Therefore, you get the error:

Type 'org.apereo.cas.configuration.model.support.jdbc.QueryJdbcAuthenticationProperties' has no property 'url'

If so, I would recommend you to rather use the CAS WAR Overlay Installation instead - it's generally easier for common CAS usage. If you still do need to touch those classes, you need to setup the Lombok as I mentioned above.

Finally, as Karan writes, you will also probably need to add an appropriate dependency on the PostgreSQL driver, so that you don't get NoClassDefFoundError or similar when your application gets further in the execution.




回答2:


your properties are setup correctly. But CAS 5.x additionally needs drivers (not always) for some databases. If you could include the following in your pom as dependency, it should provide the necessary drivers are specified in postgres driver support

Update your pom to include:

<dependency>
     <groupId>org.apereo.cas</groupId>
     <artifactId>cas-server-support-jdbc-drivers</artifactId>
     <version>${cas.version}</version>
</dependency>


来源:https://stackoverflow.com/questions/59299110/cas-database-authentication-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!