CASServerClient配置

编程

CAS 版本: 5.3.14
Spring Boot 版本: 1.5.18.RELEASE
Spring 版本: 4.3.25.RELEASE
Java 版本: 1.8.0_162
操作系统: Windows 10 64位
Apache Tomcat 版本: Apache Tomcat/8.5.53

CAS Server 安装与依赖

GutHub地址:https://github.com/apereo/cas-overlay-template/tree/5.3

执行准备命令: build.cmd copy,build.gencert

打包命令:build.cmd package

Tomcat 运行 cas.war

pom.xml完整配置

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd ">

<modelVersion>4.0.0</modelVersion>

<groupId>org.apereo.cas</groupId>

<artifactId>cas-overlay</artifactId>

<packaging>war</packaging>

<version>1.0</version>

<build>

<plugins>

<plugin>

<groupId>com.rimerosolutions.maven.plugins</groupId>

<artifactId>wrapper-maven-plugin</artifactId>

<version>0.0.5</version>

<configuration>

<verifyDownload>true</verifyDownload>

<checksumAlgorithm>MD5</checksumAlgorithm>

</configuration>

</plugin>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-maven-plugin</artifactId>

<version>${springboot.version}</version>

<configuration>

<mainClass>${mainClassName}</mainClass>

<addResources>true</addResources>

<executable>${isExecutable}</executable>

<layout>WAR</layout>

</configuration>

<executions>

<execution>

<goals>

<goal>repackage</goal>

</goals>

</execution>

</executions>

</plugin>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-war-plugin</artifactId>

<version>2.6</version>

<configuration>

<warName>cas</warName>

<failOnMissingWebXml>false</failOnMissingWebXml>

<recompressZippedFiles>false</recompressZippedFiles>

<archive>

<compress>false</compress>

<manifestFile>${manifestFileToUse}</manifestFile>

</archive>

<overlays>

<overlay>

<groupId>org.apereo.cas</groupId>

<artifactId>cas-server-webapp${app.server}</artifactId>

</overlay>

</overlays>

</configuration>

</plugin>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<version>3.3</version>

</plugin>

</plugins>

<finalName>cas</finalName>

</build>

<properties>

<cas.version>5.3.14</cas.version>

<springboot.version>1.5.18.RELEASE</springboot.version>

<!-- app.server could be -jetty, -undertow, -tomcat, or blank if you plan to provide appserver -->

<app.server>-tomcat</app.server>

<mainClassName>org.springframework.boot.loader.WarLauncher</mainClassName>

<isExecutable>false</isExecutable>

<manifestFileToUse>${project.build.directory}/war/work/org.apereo.cas/cas-server-webapp${app.server}/META-INF/MANIFEST.MF</manifestFileToUse>

<maven.compiler.source>1.8</maven.compiler.source>

<maven.compiler.target>1.8</maven.compiler.target>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

</properties>

<repositories>

<repository>

<id>alimaven</id>

<url>

http://maven.aliyun.com/nexus/content/groups/public/

</url>

<snapshots>

<enabled>false</enabled>

</snapshots>

<releases>

<enabled>true</enabled>

</releases>

</repository>

<repository>

<id>sonatype-releases</id>

<url>http://oss.sonatype.org/content/repositories/releases/</url>

<snapshots>

<enabled>false</enabled>

</snapshots>

<releases>

<enabled>true</enabled>

</releases>

</repository>

<repository>

<id>sonatype-snapshots</id>

<url>https://oss.sonatype.org/content/repositories/snapshots/</url>

<snapshots>

<enabled>true</enabled>

</snapshots>

<releases>

<enabled>false</enabled>

</releases>

</repository>

<repository>

<releases>

<enabled>true</enabled>

</releases>

<id>shibboleth-releases</id>

<url>https://build.shibboleth.net/nexus/content/repositories/releases</url>

</repository>

</repositories>

<profiles>

<profile>

<activation>

<activeByDefault>true</activeByDefault>

</activation>

<id>default</id>

<dependencies>

<dependency>

<groupId>org.apereo.cas</groupId>

<artifactId>cas-server-webapp${app.server}</artifactId>

<version>${cas.version}</version>

<type>war</type>

<scope>runtime</scope>

</dependency>

<!--

...Additional dependencies may be placed here...

-->

<dependency>

<groupId>org.apereo.cas</groupId>

<artifactId>cas-server-support-json-service-registry</artifactId>

<version>${cas.version}</version>

</dependency>

<dependency>

<groupId>javax.xml.bind</groupId>

<artifactId>jaxb-api</artifactId>

<version>2.3.0</version>

</dependency>

<dependency>

<groupId>com.sun.xml.bind</groupId>

<artifactId>jaxb-impl</artifactId>

<version>2.3.0</version>

</dependency>

<dependency>

<groupId>com.sun.xml.bind</groupId>

<artifactId>jaxb-core</artifactId>

<version>2.3.0</version>

</dependency>

<dependency>

<groupId>javax.activation</groupId>

<artifactId>activation</artifactId>

<version>1.1.1</version>

</dependency>

<dependency>

<groupId>org.apereo.cas</groupId>

<artifactId>cas-server-support-jdbc-drivers</artifactId>

<version>${cas.version}</version>

</dependency>

<dependency>

<groupId>org.apereo.cas</groupId>

<artifactId>cas-server-support-jdbc</artifactId>

<version>${cas.version}</version>

</dependency>

</dependencies>

</profile>

<profile>

<activation>

<activeByDefault>false</activeByDefault>

</activation>

<id>exec</id>

<properties>

<mainClassName>org.apereo.cas.web.CasWebApplication</mainClassName>

<isExecutable>true</isExecutable>

<manifestFileToUse></manifestFileToUse>

</properties>

<build>

<plugins>

<plugin>

<groupId>com.soebes.maven.plugins</groupId>

<artifactId>echo-maven-plugin</artifactId>

<version>0.3.0</version>

<executions>

<execution>

<phase>prepare-package</phase>

<goals>

<goal>echo</goal>

</goals>

</execution>

</executions>

<configuration>

<echos>

<echo>Executable profile to make the generated CAS web application executable.</echo>

</echos>

</configuration>

</plugin>

</plugins>

</build>

</profile>

<profile>

<activation>

<activeByDefault>false</activeByDefault>

</activation>

<id>bootiful</id>

<properties>

<app.server>-tomcat</app.server>

<isExecutable>false</isExecutable>

</properties>

<dependencies>

<dependency>

<groupId>org.apereo.cas</groupId>

<artifactId>cas-server-webapp${app.server}</artifactId>

<version>${cas.version}</version>

<type>war</type>

<scope>runtime</scope>

</dependency>

</dependencies>

</profile>

<profile>

<activation>

<activeByDefault>false</activeByDefault>

</activation>

<id>pgp</id>

<build>

<plugins>

<plugin>

<groupId>com.github.s4u.plugins</groupId>

<artifactId>pgpverify-maven-plugin</artifactId>

<version>1.1.0</version>

<executions>

<execution>

<goals>

<goal>check</goal>

</goals>

</execution>

</executions>

<configuration>

<pgpKeyServer>hkp://pool.sks-keyservers.net</pgpKeyServer>

<pgpKeysCachePath>${settings.localRepository}/pgpkeys-cache</pgpKeysCachePath>

<scope>test</scope>

<verifyPomFiles>true</verifyPomFiles>

<failNoSignature>false</failNoSignature>

</configuration>

</plugin>

</plugins>

</build>

</profile>

</profiles>

</project>

数据源配置:

pom.xml添加依赖:

                <dependency>

<groupId>org.apereo.cas</groupId>

<artifactId>cas-server-support-jdbc-drivers</artifactId>

<version>${cas.version}</version>

</dependency>

<dependency>

<groupId>org.apereo.cas</groupId>

<artifactId>cas-server-support-jdbc</artifactId>

<version>${cas.version}</version>

</dependency>

数据库连接配置:etccasconfigcas.properties

cas.authn.accept.users=

cas.authn.jdbc.query[0].sql=SELECT * FROM sys_user WHERE username = ?

cas.authn.jdbc.query[0].url=jdbc:mysql://localhost:3306/familytree?characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC

cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.MySQLDialect

cas.authn.jdbc.query[0].user=root

cas.authn.jdbc.query[0].password=root

cas.authn.jdbc.query[0].ddlAuto=none

cas.authn.jdbc.query[0].driverClass=com.mysql.cj.jdbc.Driver

cas.authn.jdbc.query[0].fieldPassword=password

cas.authn.jdbc.query[0].passwordEncoder.type=BCRYPT

支持http: 修改casWEB-INFclassesservicesHTTPSandIMAPS-10000001.json

{

"@class" : "org.apereo.cas.services.RegexRegisteredService",

"serviceId" : "^(https|http|imaps)://.*",

"name" : "HTTPS and IMAPS",

"id" : 10000001,

"description" : "This service definition authorizes all application urls that support HTTPS and IMAPS protocols.",

"evaluationOrder" : 10000

}

服务注册:JSON Service注册

pom.xml添加依赖:

<dependency>

<groupId>org.apereo.cas</groupId>

<artifactId>cas-server-support-json-service-registry</artifactId>

<version>${cas.version}</version>

</dependency>

cas.properties配置

cas.serviceRegistry.initFromJson=true

cas.serviceRegistry.json.location=classpath:/services

新建casWEB-INFclassesservicesApereo-10000002.json

内容:

{

"@class" : "org.apereo.cas.services.RegexRegisteredService",

"serviceId" : "^http://localhost",

"name" : "Apereo",

"theme" : "apereo",

"id" : 10000002,

"description" : "Apereo foundation sample service",

"evaluationOrder" : 1

}

文件命名规则:

JSON fileName = serviceName + "-" + serviceNumericId + ".json"

cas.properties完整配置

cas.server.name: http://localhost:8080

cas.server.prefix: http://localhost:8080/cas

cas.adminPagesSecurity.ip=127.0.0.1

#cas.authn.accept.users=root::root

logging.config: file:/etc/cas/config/log4j2.xml

cas.serviceRegistry.initFromJson=true

cas.serviceRegistry.json.location=classpath:/services

cas.authn.accept.users=

cas.authn.jdbc.query[0].sql=SELECT * FROM sys_user WHERE username = ?

cas.authn.jdbc.query[0].url=jdbc:mysql://localhost:3306/familytree?characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC

cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.MySQLDialect

cas.authn.jdbc.query[0].user=root

cas.authn.jdbc.query[0].password=root

cas.authn.jdbc.query[0].ddlAuto=none

cas.authn.jdbc.query[0].driverClass=com.mysql.cj.jdbc.Driver

cas.authn.jdbc.query[0].fieldPassword=password

cas.authn.jdbc.query[0].passwordEncoder.type=BCRYPT

CAS Client 单点登录配置:

演示例子:https://github.com/luzhihua407/CAS-Client-Demo.git

运行环境:

 Spring Boot 版本:2.2.5.RELEASE

Client设置

pom.xml添加依赖:

<dependency>

<groupId>com.kakawait</groupId>

<artifactId>cas-security-spring-boot-starter</artifactId>

<version>1.0.2</version>

</dependency>

application.xml 添加配置:

security:

cas:

server:

base-url: http://localhost:8080/cas

service:

base-url: http://localhost

 

以上是 CASServerClient配置 的全部内容, 来源链接: utcz.com/z/515174.html

回到顶部