跳到主内容

通过 SAML 连接 AWS Client VPN

本指南介绍如何将 Casdoor 用作 AWS Client VPN 的 SAML 身份提供商 (IdP)。


学习目标​

  • 为 AWS Client VPN 配置 Casdoor 应用。
  • 在 AWS IAM 中将 Casdoor 添加为 SAML 身份提供商。
  • 创建通过 Casdoor 对用户进行身份验证的 Client VPN 端点。
  • 连接到 VPN。

前提条件​


配置 Casdoor 应用​

  1. 在 Casdoor 管理控制台中,打开应用的编辑页面。

  2. 向 Redirect URLs 添加 urn:amazon:webservices:clientvpn。

    Redirect URLs with the AWS Client VPN identifier

  3. 将设置SAML 响应 URL为http://127.0.0.1:35001。

    SAML reply URL for AWS Client VPN

  4. 将 SAML metadata(SAML 元数据)保存为 XML 文件。您将在下一节将其上传到 AWS。

    SAML metadata of the application

在 AWS 中添加 Casdoor 作为身份提供商​

  1. 在 IAM 控制台中,转到 Identity providers 并点击 Create provider。

    Create provider in the IAM console

  2. 选择 SAML,为提供商输入名称,并上传来自 Casdoor 的元数据文件。

    Metadata upload in the IAM console

  3. 点击 Next step,然后点击 Create。

创建客户端VPN端点​

  1. 在 VPC 控制台中,转到 Client VPN Endpoints 并点击 Create Client VPN Endpoint。

    Client VPN Endpoints in the VPC console

  2. 在 Client IPv4 CIDR 中,输入远程用户的地址范围。

  3. 在 Server certificate 中,从 ACM 中选择您的证书。

  4. 在 Authentication 下,选择 User-based authentication,然后选择 Federated authentication。

  5. 选择您创建的 SAML 身份提供商。

  6. 点击创建客户端VPN端点。

    Client VPN endpoint settings

将端点与 VPC 关联​

  1. 打开端点,转到 Target network associations,并点击 Associate target network。

  2. 选择 VPC 和子网。

    Target network association

添加授权规则​

此步骤是可选的。它将网络访问限制为一组用户。

  1. 打开端点,转到 Authorization rules,并点击 Add authorize rule。

  2. 在 Destination network 中,输入 EC2 实例的网络,例如 172.31.16.0/20。

  3. 在 Grant access to 下,选择 Allow access to users in a specific access group 并输入群组名称,例如 casdoor。

  4. 添加规则。

    Authorization rule

验证结果​

  1. 在 VPC 控制台中,选择端点,等待其状态变为 Available,然后点击 Download Client Configuration。

    Download Client Configuration

  2. 在 AWS Client VPN 应用程序中,转到 File > Manage Profiles,点击 Add Profile,并选择下载的文件。

  3. 选择配置文件并单击连接。 The Casdoor sign-in page opens in your browser. After you sign in, the VPN connects.

另请参阅​