Liberty 概要文件批处理框架允许您配置基于角色的对所有批处理管理操作的访问权及查看与批处理作业相关联的元数据和日志。
开始之前
批处理容器定义了三个批处理角色。单个用户可以具有多个批处理角色。
- batchAdmin
- batchAdmin 具有对所有批处理操作的非受限访问权。这包括以下许可权:提交新作业、停止并重新启动任何用户的作业、查看批处理域中的任何用户提交的任何作业元数据和作业日志以及清除任何作业。batchAdmin
不一定是 WebSphere Application Server 管理员。
- batchSubmitter
- batchSubmitter 有权提交新作业,但只能对他们自己的作业执行停止、停止重新或清除之类的批处理操作。batchSubmitter 不能查看或修改其他用户的作业。例如,如果
user1 和 user2 都定义为 batchSubmitter,并且 user1 提交了作业,那么 user2 不能查看与 user1 的作业相关联的作业实例数据。
- batchMonitor
- batchMonitor 具有对所有作业的只读许可权。此角色的用户可以查看所有作业实例和执行,并有权访问所有作业日志。batchMonitor
不能提交自己的作业,也不能停止、重新启动或清除任何作业。
注: 启用批处理安全性后,系统将根据授予当前用户的批处理角色来过滤返回列表的任何
JobOperator API 方法或 REST 操作。例如,如果一个仅具有 batchSubmitter 许可权的用户请求所有作业实例的列表,那么系统仅返回当前用户提交的作业实例。
过程
- 缺省情况下,batch-1.0 功能部件不会启用任何安全性。对于所有用户(不管他们是否经过认证),JobOperator 方法保持开放状态。这些方法保持开放状态只是用于开发目的,不需要任何安全配置。 batchManagement-1.0 功能部件启用批处理 REST API。该 REST API
始终要求用户进行认证,即使未启用 appSecurity-2.0 功能部件也是如此,但所有用户将被视为批处理管理员并可对任何作业实例执行所有批处理操作。启用
appSecurity-2.0 后,系统将执行基于批处理角色的安全授权,用户被限制为只能执行他们被给定的批处理角色所定义的批处理操作。
- 通过 JobOperator API 启用基于批处理角色的安全性
<featureManager>
<feature>batch-1.0</feature>
<feature>appSecurity-2.0</feature>
</featureManager>
- 通过 REST API 启用基于批处理角色的安全性。
注: batchManagement-1.0 功能部件包含 batch-1.0 功能部件。
<featureManager>
<feature>batchManagement-1.0</feature>
<feature>appSecurity-2.0</feature>
</featureManager>
- 配置 server.xml 文件以支持基于角色的安全性。 以下示例说明用于定义用户列表的基本用户注册表。此注册表将由基于批处理角色的安全配置样本使用。
<basicRegistry id="basic" realm="ibm/api">
<user name="alice" password="alicepwd" />
<user name="bob" password="bobpwd" />
<user name="jane" password="janepwd" />
<user name="joe" password="joepwd" />
<user name="phyllis" password="phyllispwd" />
<user name="kai" password="kaipwd" />
</basicRegistry>
在此示例中,一个用户占用多个角色。
<authorization-roles id="com.ibm.ws.batch">
<security-role name="batchAdmin" >
<user name="alice" />
</security-role>
<security-role name="batchSubmitter" >
<user name="jane" />
<user name="phyllis" />
<user name="bob"/>
</security-role>
<security-role name="batchMonitor" >
<user name="joe" />
<user name="bob"/>
</security-role>
</authorization-roles>
在此示例中,一个用户占用多个角色。所有用户具有 batchSubmitter 角色。
<authorization-roles id="com.ibm.ws.batch">
<security-role name="batchAdmin" >
<user name="alice" />
</security-role>
<security-role name="batchSubmitter" >
<special-subject type="ALL_AUTHENTICATED_USERS"/>
</security-role>
<security-role name="batchMonitor" >
<user name="joe" />
<user name="bob"/>
</security-role>
</authorization-roles>
在此示例中,一个用户占用多个角色。所有用户(包括那些未认证用户)被允许具有 batchMonitor 角色。<authorization-roles id="com.ibm.ws.batch">
<security-role name="batchAdmin" >
<user name="alice" />
</security-role>
<security-role name="batchSubmitter" >
<user name="joe" />
<user name="bob"/>
</security-role>
<security-role name="batchMonitor" >
<special-subject type="EVERYONE"/>
</security-role>
</authorization-roles>