使用 MobileFirst Server 认证外部资源

improve this page | report issue


概述

受保护资源可在 MobileFirst Server(例如,适配器)或外部服务器上运行。 您可以使用 Mobile Foundation 随附的验证模块来保护外部服务器上的资源。

在此教程中,您将了解如何通过实施验证 MobileFirst 访问令牌过滤器来保护外部资源服务器
您可以完全使用定制代码或者使用封装部分流程的一个 Mobile Foundation helper 库来实施此类保护。

先决条件:

流程

保护外部资源图

MobileFirst Server 具有一个名为自省端点的组件,能够验证 MobileFirst 访问令牌中的数据以及从中抽取数据。 可通过 REST API 使用此自省端点。

  1. 使用 Mobile Foundation 客户机 SDK 的应用程序使用或不使用 Authorization 头(客户机访问令牌)对受保护资源进行资源请求调用(或任何 HTTP 请求)。
  2. 要与自省端点进行通信,资源服务器上的过滤器需要为自身获取单独的令牌(请参阅保密客户机部分)。
  3. 资源服务器上的过滤器通过步骤 1 抽取客户机访问令牌,并将其发送到自省端点以进行验证。
  4. 如果 MobileFirst 授权服务器确定令牌无效(或者不存在),那么资源服务器会重定向客户机以获取必需作用域的新令牌。 在使用 MobileFirst 客户机 SDK 时,本部分会在内部发生。

保密客户机

因为自省端点是作用域 authorization.introspect 保护的内部资源,所以资源服务器需要获取单独的令牌以向其发送任何数据。 如果尝试针对自省端点发出请求而不使用授权头,那么将返回 401 响应。

要使外部资源服务器能够请求 authorization.introspect 作用域的令牌,需要通过 MobileFirst Operations Console 将服务器注册为保密客户机

保密客户机教程中了解更多信息。

在 MobileFirst Operations Console 中的设置 → 保密客户机下,添加新条目。 选择客户机密钥API 密钥值。 确保将 authorization.introspect 设置为允许的作用域

配置保密客户机

实施

可通过直接对各种 REST API 发出 HTTP 请求来手动实施此流程(请参阅文档)。
Mobile Foundation 还提供库,以帮助您使用提供的信任关联拦截器WebSphere 服务器上实现此操作,或者使用提供的 Java 令牌验证程序在其他任何基于 Java 的过滤器上实现此操作:

Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.
Last modified on June 01, 2020