Compare commits

...

3 Commits

Author SHA1 Message Date
Shaun Chyxion
d635f183f9 update config 2022-01-12 00:27:46 +08:00
Shaun Chyxion
f6b8c764aa code cleanup 2022-01-07 01:28:17 +08:00
Shaun Chyxion
f39576d6cd add ldap 2022-01-07 01:09:15 +08:00
9 changed files with 136 additions and 126 deletions

View File

@ -1,6 +1,6 @@
server.port=8081
server.name=http://localhost:8080
server.prefix=${server.name}/cas
server.name=http://localhost:8081
server.prefix=${server.name}/
# security configuration based on IP address to access the /status and /statistics pages
# cas.securityContext.adminpages.ip=127\.0\.0\.1
@ -201,28 +201,7 @@ server.prefix=${server.name}/cas
# shiro.authn.requiredPermissions=
# shiro.authn.config.file=classpath:shiro.ini
##
# YubiKey Authentication
#
# yubikey.client.id=
# yubikey.secret.key=
datasource.url=jdbc:mysql://172.16.4.6/yobr-daily?useUnicode=true&characterEncoding=utf8
datasource.username=yobr_query
datasource.password=yobr_query!
##
# JDBC Authentication
#
# cas.jdbc.authn.query.encode.sql=
# cas.jdbc.authn.query.encode.alg=
# cas.jdbc.authn.query.encode.salt.static=
# cas.jdbc.authn.query.encode.password=
# cas.jdbc.authn.query.encode.salt=
# cas.jdbc.authn.query.encode.iterations.field=
# cas.jdbc.authn.query.encode.iterations=
cas.jdbc.authn.query.sql=select password from br_auth_user where account = ?
# cas.jdbc.authn.query.sql=select password from br_auth_user where account = ?
# cas.jdbc.authn.search.password=
# cas.jdbc.authn.search.user=
@ -243,16 +222,6 @@ cas.jdbc.authn.query.sql=select password from br_auth_user where account = ?
# file.authn.filename=classpath:people.txt
# file.authn.separator=::
##
# General Authentication
#
# cas.principal.transform.upperCase=false
# cas.authn.password.encoding.char=UTF-8
# cas.authn.password.encoding.alg=SHA-256
cas.authn.password.encoding.alg=MD5
# cas.principal.transform.prefix=
# cas.principal.transform.suffix=
##
# X509 Authentication
#
@ -713,3 +682,26 @@ accept.authn.users=casuser::Mellon
# cas.aup.ldap.startTLS=false
# cas.aup.ldap.basedn=dc=example,dc=org
# cas.aup.attribute=
# LDAP
cas.ldap.url=ldap://172.16.4.3:389
cas.ldap.baseDn=ou=Users,domainName=pudonghot.com,o=domains,dc=pudong-hot,dc=com
cas.ldap.authn.searchFilter=(uid={user})
cas.ldap.managerDn=cn=Manager,dc=pudong-hot,dc=com
cas.ldap.managerPassword=GrgGYa55GAq1XQxlYrI57ttkv2XoAC
cas.ldap.connectTimeout=300
cas.ldap.useStartTLS=false
cas.ldap.pool.blockWaitTime=3000
cas.ldap.allowMultipleDns=false
cas.ldap.usePasswordPolicy=false
cas.ldap.pool.minSize=4
cas.ldap.pool.maxSize=16
cas.ldap.pool.validateOnCheckout=false
cas.ldap.pool.validatePeriodically=true
cas.ldap.pool.validatePeriod=300
cas.ldap.pool.idleTime=600
cas.ldap.pool.prunePeriod=300
cas.ldap.subtree.search=true
cas.ldap.use.ssl=false

View File

@ -79,24 +79,22 @@
</Appenders>
<Loggers>
<AsyncLogger name="org.jasig" level="info" additivity="false" includeLocation="true">
<AsyncLogger name="org.jasig" level="${log.level}" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
<AppenderRef ref="casLogFile"/>
</AsyncLogger>
<!--
<AsyncLogger name="org.opensaml" level="debug" additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="casLogFile"/>
</AsyncLogger>
<AsyncLogger name="org.ldaptive" level="debug" additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="casLogFile"/>
</AsyncLogger>
<AsyncLogger name="com.hazelcast" level="debug" additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="casLogFile"/>
</AsyncLogger>
-->
<AsyncLogger name="org.ldaptive" level="${log.level}" additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="casLogFile"/>
</AsyncLogger>
<AsyncLogger name="org.apereo.cas.security" level="warn" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
<AppenderRef ref="casLogFile"/>
@ -116,10 +114,5 @@
<AppenderRef ref="console"/>
<AppenderRef ref="appLogFile"/>
</AsyncRoot>
<AsyncRoot level="error">
<AppenderRef ref="console"/>
<AppenderRef ref="errorLogFile"/>
</AsyncRoot>
</Loggers>
</Configuration>

26
pom.xml
View File

@ -35,20 +35,9 @@
<artifactId>emtomcat</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-support-jdbc</artifactId>
<artifactId>cas-server-support-ldap</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
@ -186,7 +175,6 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.jasig</groupId>
@ -229,6 +217,18 @@
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>2.17.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>

View File

@ -2,24 +2,53 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:ldaptive="http://www.ldaptive.org/schema/spring-ext"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
http://www.springframework.org/schema/beans/spring-beans.xsd
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
init-method="init"
destroy-method="close">
<property name="url" value="${datasource.url}" />
<property name="username" value="${datasource.username}" />
<property name="password" value="${datasource.password}" />
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.ldaptive.org/schema/spring-ext
http://www.ldaptive.org/schema/spring-ext.xsd">
<ldaptive:bind-search-authenticator id="authenticator"
ldapUrl="${cas.ldap.url}"
baseDn="${cas.ldap.baseDn}"
userFilter="${cas.ldap.authn.searchFilter:(uid={user})}"
bindDn="${cas.ldap.managerDn:cn=Manager,dc=pudong-hot,dc=com}"
bindCredential="${cas.ldap.managerPassword}"
connectTimeout="${cas.ldap.connectTimeout:3000}"
useStartTLS="${cas.ldap.useStartTLS:false}"
blockWaitTime="${cas.ldap.pool.blockWaitTime:3000}"
allowMultipleDns="${cas.ldap.allowMultipleDns:false}"
usePasswordPolicy="${cas.ldap.usePasswordPolicy:false}"
minPoolSize="${cas.ldap.pool.minSize:4}"
maxPoolSize="${cas.ldap.pool.maxSize:16}"
validateOnCheckOut="${cas.ldap.pool.validateOnCheckout:false}"
validatePeriodically="${cas.ldap.pool.validatePeriodically:true}"
validatePeriod="${cas.ldap.pool.validatePeriod:300}"
idleTime="${cas.ldap.pool.idleTime:600}"
prunePeriod="${cas.ldap.pool.prunePeriod:300}"
failFastInitialize="true"
subtreeSearch="${cas.ldap.subtree.search:true}"
useSSL="${cas.ldap.use.ssl:false}"
/>
<bean id="primaryAuthenticationHandler" class="org.jasig.cas.authentication.LdapAuthenticationHandler">
<constructor-arg ref="authenticator" />
<property name="principalIdAttribute" value="uid" />
<property name="principalAttributeList">
<list>
<value>uid</value>
<value>mail</value>
<value>givenName</value>
</list>
</property>
</bean>
<alias name="dataSource" alias="queryDatabaseDataSource" />
<alias name="defaultPasswordEncoder" alias="passwordEncoder" />
<alias name="queryDatabaseAuthenticationHandler" alias="primaryAuthenticationHandler" />
<alias name="plainTextPasswordEncoder" alias="passwordEncoder" />
<util:map id="authenticationHandlersResolvers">
<entry key-ref="proxyAuthenticationHandler" value-ref="proxyPrincipalResolver" />

View File

@ -116,10 +116,5 @@
<AppenderRef ref="console"/>
<AppenderRef ref="appLogFile"/>
</AsyncRoot>
<AsyncRoot level="error">
<AppenderRef ref="console"/>
<AppenderRef ref="errorLogFile"/>
</AsyncRoot>
</Loggers>
</Configuration>

View File

@ -1,16 +1,15 @@
package org.jasig.cas;
import org.jasig.cas.authentication.principal.PrincipalFactory;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.io.FileSystemResource;
import static org.junit.Assert.*;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.FileSystemResource;
import org.springframework.mock.web.MockServletContext;
import org.jasig.cas.authentication.principal.PrincipalFactory;
import org.springframework.web.context.support.XmlWebApplicationContext;
import static org.junit.Assert.*;
/**
* Unit test to verify Spring context wiring.
*
@ -24,14 +23,14 @@ public class WiringTests {
public void setUp() {
applicationContext = new XmlWebApplicationContext();
applicationContext.setConfigLocations(
"classpath:/webappContext.xml",
"file:src/main/webapp/WEB-INF/cas-servlet.xml",
"file:src/main/webapp/WEB-INF/deployerConfigContext.xml",
"file:src/main/webapp/WEB-INF/spring-configuration/*.xml");
"file:src/test/resources/webappContext.xml",
"file:src/main/resources/WEB-INF/cas-servlet.xml",
"file:src/main/resources/WEB-INF/deployerConfigContext.xml",
"file:src/main/resources/WEB-INF/spring-configuration/*.xml");
applicationContext.setServletContext(new MockServletContext(new ResourceLoader() {
@Override
public Resource getResource(final String location) {
return new FileSystemResource("src/main/webapp" + location);
return new FileSystemResource("src/main/resources" + location);
}
@Override
@ -43,12 +42,12 @@ public class WiringTests {
}
@Test
public void verifyWiring() throws Exception {
public void verifyWiring() {
assertTrue(applicationContext.getBeanDefinitionCount() > 0);
}
@Test
public void checkPrincipalFactory() throws Exception {
public void checkPrincipalFactory() {
final PrincipalFactory factory1 =
applicationContext.getBean("principalFactory", PrincipalFactory.class);
final PrincipalFactory factory2 =

View File

@ -0,0 +1,11 @@
server.port=8081
server.name=http://localhost:8080
server.prefix=${server.name}/cas
# LDAP
cas.ldap.url=ldap://172.16.4.3:389
cas.ldap.baseDn=dc=pudong-hot,dc=com
cas.ldap.authn.searchFilter=(uid={user})
cas.ldap.managerDn=cn=Manager,dc=pudong-hot,dc=com
cas.ldap.managerPassword=GrgGYa55GAq1XQxlYrI57ttkv2XoAC

View File

@ -1,44 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Configuration shutdownHook="disable">
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Properties>
<Property name="log.level">DEBUG</Property>
<Property name="log.dir">.logs</Property>
<Property name="pattern">%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t][%c{1}] %m%n</Property>
</Properties>
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d %p [%c] - &lt;%m&gt;%n"/>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%highlight{%-d{yyyy-MM-dd HH:mm:ss,SSS}}{FATAL=magenta, ERROR=magenta, WARN=magenta, INFO=magenta, DEBUG=magenta, TRACE=magenta} %highlight{%-5p}{FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=black, DEBUG=green bold, TRACE=blue} [%t][%highlight{%c{1.}}{FATAL=cyan, ERROR=cyan, WARN=cyan, INFO=cyan, DEBUG=cyan, TRACE=cyan}] %m%n"/>
</Console>
<RollingFile name="file" fileName="cas.log" append="true"
filePattern="cas-%d{yyyy-MM-dd-HH}-%i.log">
<PatternLayout pattern="%d %p [%c] - %m%n"/>
<RollingFile name="File"
fileName="${log.dir}/app.log"
filePattern="${log.dir}/$${date:yyyy-MM}/app-%d{yyyy-MM-dd}-%i.log">
<PatternLayout pattern="${pattern}" />
<Policies>
<OnStartupTriggeringPolicy />
<SizeBasedTriggeringPolicy size="10 MB"/>
<TimeBasedTriggeringPolicy />
</Policies>
</RollingFile>
<RollingFile name="perfFileAppender" fileName="target/perfStats.log" append="true"
filePattern="perfStats-%d{yyyy-MM-dd-HH}-%i.log">
<PatternLayout pattern="%m%n"/>
<Policies>
<OnStartupTriggeringPolicy />
<SizeBasedTriggeringPolicy size="10 MB"/>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="16 MB" />
</Policies>
<DefaultRolloverStrategy max="32" />
</RollingFile>
</Appenders>
<Loggers>
<Logger name="org.springframework" level="warn" />
<Logger name="org.springframework.webflow" level="warn" />
<Logger name="org.jasig" level="info">
<AppenderRef ref="file"/>
</Logger>
<Logger name="org.jasig.cas.web.flow" level="info" additivity="true">
<AppenderRef ref="file"/>
</Logger>
<Logger name="org.jasig.inspektr.audit.support.Slf4jLoggingAuditTrailManager" level="info">
<AppenderRef ref="file"/>
</Logger>
<Root level="error">
<AppenderRef ref="console"/>
<Root level="${log.level}" additivity="false">
<AppenderRef ref="File" level="${log.level}" />
<AppenderRef ref="Console" level="${log.level}" />
</Root>
</Loggers>
</Configuration>

View File

@ -1,16 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<context:annotation-config />
<context:property-override location="classpath*:application.properties" />
<util:map id="serviceThemeResolverSupportedBrowsers">
<entry key=".*iPhone.*" value="iphone"/>