CAS集成¶
CAS模块允许将GeoServer与 Central Authentication Service (CAS) 单点登录(SSO),特别是使用标准票证和代理票证。
安装¶
要安装CAS模块:
访问 website download 页面,找到您的版本,并下载: geoserver-2.24.x-cas-plugin.zip
下载链接将位于 Extensions 下一节 Security 。
警告
确保与插件匹配(示例 2.24.x 以上)版本设置为Geoserver实例的版本。
将此存档中的文件提取到
WEB-INF/lib
地理服务器安装目录。重新启动geoserver
配置¶
CAS集成是一个身份验证筛选器模块,因此要使用它,必须:
转到authentication页面,添加CAS过滤器并配置它
将其添加到身份验证链中,注意删除其他身份验证方法(否则CAS身份验证不会触发并将用户重定向到CAS登录页)
此页用作配置选项的参考,但也提供了分步教程,请参阅 使用CA进行身份验证 .
键 |
描述 |
---|---|
名字 |
筛选器的名称 |
包含上下文根的CAS服务器URL |
CAS服务器位置(GeoServer将重定向到该位置,例如,为了登录,添加必要的额外路径元素) |
无单一登录 |
如果checkecd,将向CAS服务器发送“renew=true”选项,强制用户在每次请求时登录服务器(除非允许创建会话) |
参与单一注销 |
GeoServer是否应接收和处理单次注销的回调。 |
CAS loutput页面中的URL |
CAS注销页面位置 |
代理回调URL |
URL CA将在代理票证身份验证后回调 |
角色来源 |
通过CAS认证的用户的角色源选择 |
专门针对 role source ,有以下选项可用:
来源 |
描述 |
---|---|
用户组服务 |
找到指定用户组服务中的用户,从中提取角色。 |
角色服务 |
从指定的角色服务定位用户角色 |
标题属性 |
在CAS响应的指定HTTP标头中查找角色 |
自定义CAS属性 |
中的CAS自定义属性中提取角色 |
CAS配置示例¶
为了使用CAS自定义属性,必须将服务器配置为从给定的属性存储库提取属性,然后允许在GeoServer服务配置中释放这些属性。
例如,以下内容 cas.properties
文件设置JDBC用户源和JDBC属性存储库(此配置文件可能用于测试目的,但不能用于生产设置):
cas.server.name=https://localhost:8443
cas.server.prefix=${cas.server.name}/cas
server.ssl.key-store=file:/etc/cas/config/thekeystore
server.ssl.key-store-password=changeit
logging.config=file:/etc/cas/config/log4j2.xml
# cas.authn.accept.users=
cas.authn.jdbc.query[0].driver-class=org.postgresql.Driver
cas.authn.jdbc.query[0].url=jdbc:postgresql://localhost:5432/cas_users
cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.PostgreSQL95Dialect
cas.authn.jdbc.query[0].driver-class=org.postgresql.Driver
cas.authn.jdbc.query[0].user=theDbUser
cas.authn.jdbc.query[0].password=theDbPassword
cas.authn.jdbc.query[0].sql=SELECT * FROM users WHERE email = ?
cas.authn.jdbc.query[0].password-encoder.type=BCRYPT
cas.authn.jdbc.query[0].field-password=password
cas.authn.jdbc.query[0].field-expired=expired
cas.authn.jdbc.query[0].field-disabled=disabled
cas.authn.attributeRepository.jdbc[0].driver-class=org.postgresql.Driver
cas.authn.attributeRepository.jdbc[0].url=jdbc:postgresql://localhost:5432/cas_users
cas.authn.attributeRepository.jdbc[0].dialect=org.hibernate.dialect.PostgreSQL95Dialect
cas.authn.attributeRepository.jdbc[0].driver-class=org.postgresql.Driver
cas.authn.attributeRepository.jdbc[0].user=theDbUser
cas.authn.attributeRepository.jdbc[0].password=theDbPassword
cas.authn.attributeRepository.jdbc[0].attributes.role=role
cas.authn.attributeRepository.jdbc[0].singleRow=false
cas.authn.attributeRepository.jdbc[0].columnMappings.attribute=value
cas.authn.attributeRepository.jdbc[0].sql=SELECT * FROM roles WHERE {0}
cas.authn.attributeRepository.jdbc[0].username=email
cas.service-registry.json.location=classpath:/services
数据库有以下两个用户和角色表:
CREATE TABLE public.users (
id bigint NOT NULL,
disabled boolean,
email character varying(40),
first_name character varying(40),
last_name character varying(40),
expired boolean,
password character varying(100)
);
CREATE TABLE public.roles (
email character varying,
attribute character varying,
value character varying
);
GeoServer的示例服务配置可能如下所示(同样,设置仅用于测试和开发):
{
"@class" : "org.apereo.cas.services.RegexRegisteredService",
"serviceId" : "^http(s)?://localhost:[\\d]+/geoserver/.*",
"name" : "GeoServer",
"id" : 1002,
"logoutType" : "BACK_CHANNEL",
"logoutUrl" : "https://localhost:8442/geoserver",
"redirectUrl" : "https://localhost:8442/geoserver",
"proxyPolicy" : {
"@class" : "org.apereo.cas.services.RegexMatchingRegisteredServiceProxyPolicy",
"pattern" : "^http(s)?://localhost:[\\d]+/geoserver/.*"
},
"attributeReleasePolicy" : {
"@class" : "org.apereo.cas.services.ReturnAllAttributeReleasePolicy"
}
}
配置Web链¶
可以将CAS身份验证包括在Web筛选器链中,根据所包括的筛选器的不同具有不同的行为。下面讨论三个可能的示例。
作为第一种情况,让我们考虑在“Web”筛选器链中只有CAS身份验证:
由于不允许匿名访问,任何访问Geoserver Web控制台的尝试都将导致重定向到CAS服务器以进行登录。登录后,用户界面会显示一个按钮,用于启动CAS注销(注销在所有示例中共享,不会在下面的文本中重复)。
第二种选择是在Web链中允许匿名访问,允许用户无需登录即可访问层预览和其他演示功能:
在这种情况下,Web控制台不会立即重定向到CAS服务器,而是提供CAS登录按钮:
最后一个例子是,让我们考虑在Web链中同时登录CAS和Form:
这既允许CAS登录,也允许使用Geoserver本地用户名/密码进行基于表单的登录。在CAS服务器出于任何原因离线时允许Geoserver管理可能很有用。在这种情况下,表单登录和CAS登录按钮同时出现: