amazon-web-services - 带有自定义 SAML 应用程序的 AWS SSO 'no

我正在尝试使用 AWS SSO 设置自定义 SAML 2.0 应用程序。 但是,网络选项卡出现以下错误:

Status code 403
{"message":"No access","__type":"com.amazonaws.switchboard.portal#ForbiddenException"}

这个显示在 UI 中:

可能导致此错误的两个注意事项:

  1. 我的 SP 测试服务器在本地主机上运行
  2. 我正在使用自签名证书:
openssl req -x509 -newkey rsa:2048 -keyout myservice.key -out myservice.cert -days 365 -nodes -subj "/CN=localhost:9000"

如果这仍然不能告诉您任何信息,那么我将在下面进行更多描述。


更多详情

这是来 self 正在使用的库的服务器代码

func hello(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hello, %s!", samlsp.AttributeFromContext(r.Context(), "cn"))
}

func main() {
    keyPair, err := tls.LoadX509KeyPair("myservice.cert", "myservice.key")
    if err != nil {
        panic(err) // TODO handle error
    }
    keyPair.Leaf, err = x509.ParseCertificate(keyPair.Certificate[0])
    if err != nil {
        panic(err) // TODO handle error
    }

    idpMetadataURL, err := url.Parse("https://portal.sso.<my aws region>.amazonaws.com/saml/metadata/<some jewbrish id>")
    if err != nil {
        panic(err) // TODO handle error
    }
    idpMetadata, err := samlsp.FetchMetadata(context.Background(), http.DefaultClient,
        *idpMetadataURL)
    if err != nil {
        panic(err) // TODO handle error
    }

    rootURL, err := url.Parse("http://localhost:9000")
    if err != nil {
        panic(err) // TODO handle error
    }

    samlSP, _ := samlsp.New(samlsp.Options{
        URL:            *rootURL,
        Key:            keyPair.PrivateKey.(*rsa.PrivateKey),
        Certificate:    keyPair.Leaf,
        IDPMetadata: idpMetadata,
    })
    app := http.HandlerFunc(hello)
    http.Handle("/hello", samlSP.RequireAccount(app))
    http.Handle("/saml/", samlSP)
    http.ListenAndServe(":8000", nil)
}

此服务器公开了一个端点,IDP 可以从中获取我自动生成的元数据。

curl -o metadata.xml http://localhost:9000/saml/metadata

那些是我的元数据:

<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" validUntil="2021-09-13T03:37:23.951Z" entityID="http://localhost:9000/saml/metadata">
  <SPSSODescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" validUntil="2021-09-13T03:37:23.951204335Z" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol" AuthnRequestsSigned="false" WantAssertionsSigned="true">
    <KeyDescriptor use="encryption">
      <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
        <X509Data>
          <X509Certificate>xxxxxxxxxx</X509Certificate>
        </X509Data>
      </KeyInfo>
      <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"></EncryptionMethod>
      <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes192-cbc"></EncryptionMethod>
      <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"></EncryptionMethod>
      <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"></EncryptionMethod>
    </KeyDescriptor>
    <SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="http://localhost:9000/saml/slo" ResponseLocation="http://localhost:9000/saml/slo"></SingleLogoutService>
    <AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="http://localhost:9000/saml/acs" index="1"></AssertionConsumerService>
  </SPSSODescriptor>
</EntityDescriptor>

我已将这些上传到 AWS SSO 并且它正确解析了它,以下是我的 AWS SSO 自定义应用程序的配置:

当我点击 localhost:9000/hello 时,应用程序将成功重定向到 AWS SSO 登录控制台,但会发生该错误。 我还使用此网站测试了该应用程序:https://samltest.id/upload.php并且效果很好。

最佳答案

我找到了解决方案,问题出在属性映射中,这是我必须使用的配置才能使其正常工作。

注意 transient 格式选项,在我之前的配置中它是未指定

关于amazon-web-services - 带有自定义 SAML 应用程序的 AWS SSO 'no access error',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69140345/

相关文章:

r - 如何根据列中的两个值过滤行?

python - AES CTR解密: Cryptography and Cryptodome gi

c - 有没有办法从未知字节设置/清除位,同时保持所有其他位不变?

c# - 如何在 C# 中使用预处理器指令仅在 Windows 10 上执行一些代码?

docker - 使用 deps.edn 在容器中安装依赖项

c++ - 在 constexpr 分支中使用枚举类值

c - 栈在使用Pthread的多线程程序中是如何工作的?

c# - Parallel.Foreach 和每个产生不同的结果 : Why is my code

c++ - 在 "Effective Modern C++"示例中在索引运算符之前使用 std::f

flutter - 如何在 flutter 中的行之间写 OR