2) CAS Management
- 版本:5.1.8
- 框架代码
- 构建工具:Maven
- 构建方式:overlay
特性
- 对接入单点登录的服务进行统一管理
- 服务持久化配置(NoSql,JPA)
- UI界面配置管理
a. 下载代码包
通过官网提供的地址,找到对应版本进行下载
下载完成即可导入IDE了
b. 调整配置
- pom.xml
- application.properties
- 新增SpringBootApplication
pom.xml
由于调整的比较大,就贴出来了,为了idea有提示,加入了spring-starter-web
,与sso-server
大同小异
<?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>com.kawhii.auth</groupId>
<artifactId>sso-management</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>CAS Management</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-bom</artifactId>
<version>${cas.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>
<configuration>
<mainClass>org.springframework.boot.loader.WarLauncher</mainClass>
<addResources>true</addResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warName>cas-management</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
<recompressZippedFiles>false</recompressZippedFiles>
<archive>
<compress>false</compress>
<manifestFile>${project.build.directory}/war/work/org.apereo.cas/cas-management-webapp/META-INF/MANIFEST.MF</manifestFile>
</archive>
<overlays>
<overlay>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-management-webapp</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-management</finalName>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-management-webapp</artifactId>
<version>${cas.version}</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
</dependencies>
<properties>
<cas.version>5.1.8</cas.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springboot.version>1.5.3.RELEASE</springboot.version>
</properties>
<!--为了加快速度,修改成国内的代理-->
<repositories>
<repository>
<releases>
<enabled>true</enabled>
</releases>
<id>maven2-release</id>
<url>http://repo2.maven.org/maven2/</url>
</repository>
</repositories>
</project>
application.properties
这时我们能明确知道服务访问方式:
- sso-server http://localhost:8080
- sso-mgnt http://loclahost:8443/cas-management
server.port=8443
server.context-path=/cas-management
server.ssl.enabled=false
##
# Log4J Configuration
#
server.context-parameters.isLog4jAutoInitializationDisabled=true
##
# CAS
#
cas.server.name=http://localhost:8080
cas.server.prefix=${cas.server.name}
cas.mgmt.serverName=http://localhost:8443
c. 允许服务登录
这时需要sso-server
允许sso-management
进行登录
在sso-server中配置
applicaiton.properties
新增允许自初始化json,默认加载resources/service/*.json
cas.serviceRegistry.initFromJson=true
HTTP-10000000.json
允许所有以http方式过来登录的服务
{
"@class" : "org.apereo.cas.services.RegexRegisteredService",
"serviceId" : "^(http)://.*",
"name" : "HTTP",
"id" : 10000000,
"description" : "This service definition authorizes all application urls that support HTTP protocols.",
"evaluationOrder" : 10000
}
d. 启动测试
sso-server
先打包(build.cmd package)sso-server
,进行java -jar cas.war
运行
启动后,控制台应有以下字眼则为正确
o.a.cas.services.DefaultServicesManager : Loaded [3] service(s) from [InMemoryServiceRegistry].
sso-magement
先打包(build.cmd package)sso-server
,进行java -jar cas-mnagement.war
运行
e. 访问测试
http://localhost:8443/cas-management
访问后浏览器自动跳转到:
http://localhost:8080/login?service=http%3A%2F%2Flocalhost%3A8443%2Fcas-management%2Fmanage.html
则为正确
登录成功后如下图所示:
f. 温馨提示
并不是所有用户都可以进入CAS Management,可以设置