“description”: “CasClient-demo service”,
“evaluationOrder”: 100,
“theme”:“apereo”,
“logoutUrl”: “http://localhost:8080/sample/” ,
“attributeReleasePolicy” : {
“@class” : “org.apereo.cas.services.ReturnAllAttributeReleasePolicy”
}
}
以上配置为允许所有属性返回,若是允许部分属性,则
只允许school、email返回
“attributeReleasePolicy” : {
“@class” : “org.apereo.cas.services.ReturnAllowedAttributeReleasePolicy”,
“allowedAttributes” : [ “java.util.ArrayList”, [ “school”, “email” ] ]
}
属性查询配置
application.properties
多属性返回开始
###单行
key为数据库的列,value为输出属性的key
cas.authn.attributeRepository.jdbc[0].attributes.email=email
cas.authn.attributeRepository.jdbc[0].attributes.address=address
cas.authn.attributeRepository.jdbc[0].attributes.age=age
cas.authn.attributeRepository.jdbc[0].singleRow=true
cas.authn.attributeRepository.jdbc[0].order=0
cas.authn.attributeRepository.jdbc[0].url=${cas.authn.jdbc.query[0].url}
以下属性为查询sql时,当为多个时逗号分隔,如填写username、email,sql会变成 select * from sys_user where username= ? a n d / o r e m a i l = {?} {and/or} email= ?and/oremail={?}
cas.authn.attributeRepository.jdbc[0].username=username,email
cas.authn.attributeRepository.jdbc[0].queryType=OR
cas.authn.attributeRepository.jdbc[0].user=${cas.authn.jdbc.query[0].user}
cas.authn.attributeRepository.jdbc[0].password=${cas.authn.jdbc.query[0].password}
cas.authn.attributeRepository.jdbc[0].sql=select * from sys_user where {0}
cas.authn.attributeRepository.jdbc[0].dialect=${cas.authn.jdbc.query[0].dialect}
cas.authn.attributeRepository.jdbc[0].ddlAuto=none
cas.authn.attributeRepository.jdbc[0].driverClass=${cas.authn.jdbc.query[0].driverClass}
cas.authn.attributeRepository.jdbc[0].leakThreshold=10
cas.authn.attributeRepository.jdbc[0].propagationBehaviorName=PROPAGATION_REQUIRED
cas.authn.attributeRepository.jdbc[0].batchSize=1
cas.authn.attributeRepository.jdbc[0].failFast=true
#多行
cas.authn.attributeRepository.jdbc[1].attributes.group=group_multi
cas.authn.attributeRepository.jdbc[1].attributes.school=school_multi
#键值对
cas.authn.attributeRepository.jdbc[1].columnMappings.ATTR_KEY=ATTR_VAL
cas.authn.attributeRepository.jdbc[1].singleRow=false
cas.authn.attributeRepository.jdbc[1].order=1
cas.authn.attributeRepository.jdbc[1].url=${cas.authn.jdbc.query[0].url}
cas.authn.attributeRepository.jdbc[1].username=username
cas.authn.attributeRepository.jdbc[1].user=${cas.authn.jdbc.query[0].user}
cas.authn.attributeRepository.jdbc[1].password=${cas.authn.jdbc.query[0].password}
cas.authn.attributeRepository.jdbc[1].sql=select * from sys_attrs where {0}
cas.authn.attributeRepository.jdbc[1].dialect=${cas.authn.jdbc.query[0].dialect}
cas.authn.attributeRepository.jdbc[1].ddlAuto=none
cas.authn.attributeRepository.jdbc[1].driverClass=${cas.authn.jdbc.query[0].driverClass}
cas.authn.attributeRepository.jdbc[1].leakThreshold=10
cas.authn.attributeRepository.jdbc[1].propagationBehaviorName=PROPAGATION_REQUIRED
cas.authn.attributeRepository.jdbc[1].batchSize=1
cas.authn.attributeRepository.jdbc[1].failFast=true
多属性返回结束
数据
看看多行的数据如何列举
表结构:
/*
账号表
*/
CREATE TABLE SYS_USER (
USERNAME VARCHAR(30) PRIMARY KEY,
PASSWORD VARCHAR(64) NOT NULL,
EMAIL VARCHAR(50),
ADDRESS VARCHAR(100),
AGE INT,
EXPIRED INT,
DISABLE INT
);
/*
- 用户属性表
*/
CREATE TABLE SYS_ATTRS (
USERNAME VARCHAR(30) NOT NULL,
ATTR_KEY VARCHAR(50) NOT NULL,
ATTR_VAL VARCHAR(100) NOT NULL
);
数据:
—明文MD5数据
/123/
INSERT INTO SYS_USER VALUES (‘admin’, ‘202cb962ac59075b964b07152d234b70’, ‘huang.xx@foxmail.com’, ‘广州天河’, 27, 0, 0);
—用户属性表
INSERT INTO SYS_ATTRS VALUES (‘admin’, ‘group’, ‘ADMIN_ROLE’);
INSERT INTO SYS_ATTRS VALUES (‘admin’, ‘group’, ‘MANAGEMENT_ROLE’);
INSERT INTO SYS_ATTRS VALUES (‘admin’, ‘group’, ‘DEV_ROLE’);
INSERT INTO SYS_ATTRS VALUES (‘admin’, ‘school’, ‘GuangZhou’);
INSERT INTO SYS_ATTRS VALUES (‘admin’, ‘school’, ‘ZhuHai’);
INSERT INTO SYS_ATTRS VALUES (‘zhangsan’, ‘group’, ‘DEV_ROLE’);
测试结果
====