cas5.3.2单点登录-服务管理cas-management部署(二十二)

原文地址,转载请注明出处: https://blog.csdn.net/qq_34021712/article/details/82320332     ©王赛超 

本来这篇内容应该放到动态添加service之后讲的,决定放到最后,cas-management可以在线配置添加网站登录到cas服务器上,废话不说了,直接进入部署过程。

参考官网

https://apereo.github.io/cas/5.3.x/installation/Installing-ServicesMgmt-Webapp.html

搭建过程

pom.xml

pom是直接下载zip然后编译拷贝过来的。


<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.0modelVersion>
    <groupId>org.apereo.casgroupId>
    <artifactId>cas-services-management-overlayartifactId>
    <packaging>warpackaging>
    <version>1.0version>

    <build>
        <plugins>
            <plugin>
                <groupId>com.rimerosolutions.maven.pluginsgroupId>
                <artifactId>wrapper-maven-pluginartifactId>
                <version>0.0.4version>
                <configuration>
                    <verifyDownload>trueverifyDownload>
                    <checksumAlgorithm>MD5checksumAlgorithm>
                configuration>
            plugin>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
                <version>${springboot.version}version>
                <configuration>
                    <mainClass>${mainClassName}mainClass>
                    <addResources>trueaddResources>
                    <executable>${isExecutable}executable>
                    <layout>WARlayout>
                configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackagegoal>
                        goals>
                    execution>
                executions>
            plugin>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-war-pluginartifactId>
                <version>2.6version>
                <configuration>
                    <warName>cas-managementwarName>
                    <failOnMissingWebXml>falsefailOnMissingWebXml>
                    <recompressZippedFiles>falserecompressZippedFiles>
                    <archive>
                        <compress>falsecompress>
                        <manifestFile>${manifestFileToUse}manifestFile>
                    archive>
                    <overlays>
                        <overlay>
                            <groupId>org.apereo.casgroupId>
                            <artifactId>cas-management-webappartifactId>
                        overlay>
                    overlays>
                configuration>
            plugin>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <version>3.3version>
            plugin>
        plugins>
        <finalName>cas-managementfinalName>
    build>

    <dependencies>
        <dependency>
            <groupId>org.apereo.casgroupId>
            <artifactId>cas-management-webappartifactId>
            <version>${cas.version}version>
            <type>wartype>
        dependency>
    dependencies>

    <properties>
        <cas.version>5.3.1cas.version>
        <springboot.version>1.5.14.RELEASEspringboot.version>
        <mainClassName>org.springframework.boot.loader.WarLaunchermainClassName>
        <isExecutable>falseisExecutable>
        <manifestFileToUse>${project.build.directory}/war/work/org.apereo.cas/cas-management-webapp/META-INF/MANIFEST.MFmanifestFileToUse>

        <maven.compiler.source>1.8maven.compiler.source>
        <maven.compiler.target>1.8maven.compiler.target>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    properties>

    <repositories>
        <repository>
            <id>sonatype-releasesid>
            <url>http://oss.sonatype.org/content/repositories/releases/url>
            <snapshots>
                <enabled>falseenabled>
            snapshots>
            <releases>
                <enabled>trueenabled>
            releases>
        repository>
        <repository>
            <id>sonatype-snapshotsid>
            <url>https://oss.sonatype.org/content/repositories/snapshots/url>
            <snapshots>
                <enabled>trueenabled>
            snapshots>
            <releases>
                <enabled>falseenabled>
            releases>
        repository>
        <repository>
            <id>shibboleth-releasesid>
            <url>https://build.shibboleth.net/nexus/content/repositories/releasesurl>
        repository>
    repositories>

    <profiles>
        <profile>
            <activation>
                <activeByDefault>trueactiveByDefault>
            activation>
            <id>execid>
            <properties>
                <mainClassName>org.apereo.cas.mgmt.web.CasManagementWebApplicationmainClassName>
                <isExecutable>trueisExecutable>
                <manifestFileToUse>manifestFileToUse>
            properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.soebes.maven.pluginsgroupId>
                        <artifactId>echo-maven-pluginartifactId>
                        <version>0.3.0version>
                        <executions>
                            <execution>
                                <phase>prepare-packagephase>
                                <goals>
                                    <goal>echogoal>
                                goals>
                            execution>
                        executions>
                        <configuration>
                            <echos>
                                <echo>Executable profile to make the generated CAS management application executable.echo>echos>
                        configuration>
                    plugin>
                plugins>
            build>
        profile>

        <profile>
            <activation>
                <activeByDefault>falseactiveByDefault>
            activation>
            <id>pgpid>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.s4u.pluginsgroupId>
                        <artifactId>pgpverify-maven-pluginartifactId>
                        <version>1.1.0version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>checkgoal>
                                goals>
                            execution>
                        executions>
                        <configuration>
                            <pgpKeyServer>hkp://pool.sks-keyservers.netpgpKeyServer>
                            <pgpKeysCachePath>${settings.localRepository}/pgpkeys-cachepgpKeysCachePath>
                            <scope>testscope>
                            <verifyPomFiles>trueverifyPomFiles>
                            <failNoSignature>falsefailNoSignature>
                        configuration>
                    plugin>
                plugins>
            build>
        profile>
    profiles>
project>

application.properties

##
# CAS Thymeleaf Views
#
spring.thymeleaf.cache=false
spring.thymeleaf.mode=HTML
spring.thymeleaf.order=1

##
# Embedded CAS Tomcat Container
#
server.context-path=/cas-management
server.port=8444
server.ssl.enabled=true
server.ssl.key-store=file:/Users/wangsaichao/Desktop/tomcat.keystore
server.ssl.key-store-password=changeit
server.ssl.key-password=changeit
#先根据以下命令查看别名,别名不能乱写
#keytool -list -keystore /Users/wangsaichao/Desktop/tomcat.keystore
server.ssl.keyAlias=tomcat

##
# Log4J Configuration
#
server.context-parameters.isLog4jAutoInitializationDisabled=true
# logging.config=file:/etc/cas/log4j2.xml

##
# CAS Server
#
cas.server.name=https://server.cas.com:8443
cas.server.prefix=${cas.server.name}/cas

##
# CAS Authentication Attributes
#
cas.authn.attributeRepository.stub.attributes.uid=uid
cas.authn.attributeRepository.stub.attributes.givenName=givenName
cas.authn.attributeRepository.stub.attributes.eppn=eppn


mgmt.serverName=https://server.cas.com:${server.port}

##
# CAS Web Application Config
#
server.session.timeout=1800
server.session.cookie.http-only=true
server.session.tracking-modes=COOKIE

##
# CAS Cloud Bus Configuration
# Please leave spring.cloud.bus.enabled set to false
#
spring.cloud.bus.enabled=false

#Indicates that systemPropertiesOverride can be used.
# Set to false to prevent users from changing the default accidentally. Default true.
spring.cloud.config.allow-override=true

# External properties should override system properties.
spring.cloud.config.override-system-properties=false

# When allowOverride is true, external properties should take lowest priority, and not override any
# existing property sources (including local config files).
spring.cloud.config.override-none=false

##
# Actuator Endpoint Security Defaults
#
endpoints.sensitive=true
endpoints.enabled=false
endpoints.actuator.enabled=false

user-details.properties

在resource根目录下创建可用于操作的用户信息的配置文件

# username=password,grantedAuthority[,grantedAutority][,enabled|disabled]
admin=123456,ROLE_ADMIN,ROLE_ACTUATOR
test=123456,ROLE_ADMIN

启动测试

cas5.3.2单点登录-服务管理cas-management部署(二十二)_第1张图片

开启持久化

持久化就跟我们之前讲的动态添加service一样,将service信息存储到数据库,不懂的可以看一下之前的博客。

pom添加依赖

<dependency>
    <groupId>org.apereo.casgroupId>
    <artifactId>cas-server-support-jdbc-driversartifactId>
    <version>${cas.version}version>
dependency>
<dependency>
    <groupId>mysqlgroupId>
    <artifactId>mysql-connector-javaartifactId>
    <version>5.1.36version>
dependency>
<dependency>
    <groupId>org.apereo.casgroupId>
    <artifactId>cas-server-support-jpa-service-registryartifactId>
    <version>${cas.version}version>
dependency>

application.properties添加以下属性

#数据库用户名
cas.serviceRegistry.jpa.user=root
#数据库密码
cas.serviceRegistry.jpa.password=123456
#mysql驱动
cas.serviceRegistry.jpa.driverClass=com.mysql.jdbc.Driver
#数据库连接
cas.serviceRegistry.jpa.url=jdbc:mysql://127.0.0.1:3306/testshiro?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
cas.serviceRegistry.jpa.dialect=org.hibernate.dialect.MySQL5Dialect
#连接池配置
cas.serviceRegistry.jpa.pool.suspension=false
cas.serviceRegistry.jpa.pool.minSize=6
cas.serviceRegistry.jpa.pool.maxSize=18
cas.serviceRegistry.jpa.pool.maxWait=2000
cas.serviceRegistry.jpa.pool.timeoutMillis=1000
#默认为create-drop,表示每次启动服务都会清除你之前注册的cas服务
#create-drop 重启cas服务的时候,干掉新建
#create  没有表就创建,有就不创建
#none 一直都有
#update 更新
cas.serviceRegistry.jpa.ddlAuto=create-drop

再次启动测试

你可能感兴趣的:(cas,CAS学习)