简体   繁体   English

AWS Cognito - 具有联合身份提供商的用户池

[英]AWS Cognito - User Pools with Federated Identity providers

I am new to AWS and learning about Cognito Pools.我是 AWS 的新手,正在学习 Cognito Pools。

I am planning to use Cognito userpools connected with Cognito Federated Identity pool.我计划使用与 Cognito 联合身份池连接的 Cognito 用户池。 I do not want to use Login with hosted UI feature or any other login UI to log in.我不想使用带有托管 UI 功能的登录或任何其他登录 UI 来登录。

Is the following true/possible :-以下是否正确/可能:-

  • From back end on calling some Cognito API with username and password it can automatically call the configured User pool Federated Identity provider to authenticate the user and then generate the JWT token.从后端调用一些带有用户名和密码的 Cognito API,它可以自动调用配置的用户池联合身份提供程序来验证用户,然后生成 JWT 令牌。 If yes can you please refer/guide me please.如果是,请您参考/指导我。
  • User present in Identity provider does not exist in AWS user pool.身份提供商中存在的用户在 AWS 用户池中不存在。 Is it possible to authenticate the user with configured Identity provider without the user being present in AWS user pool?是否可以在 AWS 用户池中不存在用户的情况下使用配置的身份提供商对用户进行身份验证? If yes then will the user be created in AWS User pool after authentication?如果是,那么在身份验证后会在 AWS 用户池中创建用户吗?

I will really appreciate any help.我真的很感激任何帮助。 Thanks in advance.提前致谢。

From back end on calling some Cognito API with username and password it can automatically call the configured User pool Federated Identity provider to authenticate the user and then generate the JWT token.从后端调用一些带有用户名和密码的 Cognito API,它可以自动调用配置的用户池联合身份提供程序来验证用户,然后生成 JWT 令牌。 If yes can you please refer/guide me please.如果是,请您参考/指导我。

This is possible.这个有可能。 You can use a combination of the following two references.您可以组合使用以下两个参考。

Receiving the JWT token from Cognito UserPools 从 Cognito UserPools 接收 JWT 令牌

    var authenticationData = {
        Username : 'username',
        Password : 'password',
    };
    var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails(authenticationData);
    var poolData = { UserPoolId : 'us-east-1_xxxxx',
        ClientId : 'xxxxxxxxxxxxxxxx'
    };
    var userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);
    var userData = {
        Username : 'username',
        Pool : userPool
    };
    var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
    cognitoUser.authenticateUser(authenticationDetails, {
        onSuccess: function (result) {
            console.log('access token + ' + result.getAccessToken().getJwtToken());
            /*Use the idToken for Logins Map when Federating User Pools with identity pools or when passing through an Authorization Header to an API Gateway Authorizer*/
            console.log('idToken + ' + result.idToken.jwtToken);
        },

        onFailure: function(err) {
            alert(err);
        },

    });

Pass the JWT Token to the Cognito Federated Identity Pool via SDK and exchange for AWS Temporary access credentials to perform any action against AWS provisioning.通过开发工具包将 JWT 令牌传递到Cognito 联合身份池并交换 AWS 临时访问凭证以针对 AWS 配置执行任何操作。

AWS.config.credentials = new AWS.CognitoIdentityCredentials({
   IdentityPoolId: 'us-east-1:xxxxxxx-xxxx-xxxx-xxxx-xxxxxx',
   Logins: {
      'cognito-idp.us-east-1.amazonaws.com/us-east-1_xxxxxx': result.idToken.jwtToken
   }
});

User present in Identity provider does not exist in AWS user pool.身份提供商中存在的用户在 AWS 用户池中不存在。 Is it possible to authenticate the user with configured Identity provider without the user being present in AWS user pool?是否可以在 AWS 用户池中不存在用户的情况下使用配置的身份提供商对用户进行身份验证? If yes then will the user be created in AWS User pool after authentication?如果是,那么在身份验证后会在 AWS 用户池中创建用户吗?

This is only possible if your external Identity Provider supports SAML Federation.这仅在您的外部身份提供者支持 SAML 联合时才有可能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将Cognito用户池与Cognito联合身份池集成 - How to integrate Cognito User Pools with Cognito Federated Identity Pools 如何将 API 网关与 Cognito 联合身份和 Cognito 用户池集成 - How to integrate API Gateway with Cognito Federated Identity and Cognito User Pools 带有用户池和联合社交身份提供商的AWS Mobile Hub示例应用 - AWS Mobile Hub sample app with User Pools and Federated Social Identity Providers Amazon Cognito用户池与联合身份提供者 - Amazon Cognito user pool v/s federated identity providers AWS Cognito&Lambda:将联合身份添加到用户池 - AWS Cognito & Lambda: add federated identity to user pool Cognito 用户池和联合身份之间的 aws 服务差异 - aws service difference between cognito user pool and federated identity 我可以使用 Cloudformation 设置 AWS Cognito 用户池身份提供商吗? - Can I setup AWS Cognito User Pool Identity Providers with Cloudformation? 使用Cognito用户池中的Cognito联合身份的execute-api - execute-api with Cognito federated identities from Cognito user pools AWS Cognito用户池和OpenId - AWS Cognito User Pools and OpenId 卓(AWS):如何根据Cognito池正确认证用户并将其用于Cognito联合身份? - AWS: How to properly authenticate a user against Cognito Pool and use it for Cognito Federated Identity?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM