gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 09:31:01 24 4
gpt4 key购买 nike

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

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

这个显示在 UI 中:

enter image description here

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

  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 自定义应用程序的配置:

enter image description here

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

最佳答案

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

enter image description here

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

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com