Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 如何使用AWS cognito和API网关创建基于角色的web应用程序_Amazon Web Services_Spring Boot_Aws Api Gateway_Amazon Cognito - Fatal编程技术网

Amazon web services 如何使用AWS cognito和API网关创建基于角色的web应用程序

Amazon web services 如何使用AWS cognito和API网关创建基于角色的web应用程序,amazon-web-services,spring-boot,aws-api-gateway,amazon-cognito,Amazon Web Services,Spring Boot,Aws Api Gateway,Amazon Cognito,我是AWS的新手。我使用AWS cognito进行用户登录和注册,使用AWS API网关管理端点。我的后端是Spring boot。但我不知道如何将角色分配给每个用户。当我参考文档时,它说首先在用户池中创建用户,然后创建一个组来赋予角色 我在这里感到困惑。该组是使用IAM角色创建的,这意味着允许访问AWS服务。我希望每个用户都不需要IAM角色。我的角色可能是角色用户、角色管理员、角色超级管理员、角色雇主 但我正在实现一个基于web的系统。我需要在后端设置一个安全层来授予访问每个端点的权限(我不知

我是AWS的新手。我使用AWS cognito进行用户登录和注册,使用AWS API网关管理端点。我的后端是Spring boot。但我不知道如何将角色分配给每个用户。当我参考文档时,它说首先在用户池中创建用户,然后创建一个组来赋予角色

我在这里感到困惑。该组是使用IAM角色创建的,这意味着允许访问AWS服务。我希望每个用户都不需要IAM角色。我的角色可能是角色用户、角色管理员、角色超级管理员、角色雇主

但我正在实现一个基于web的系统。我需要在后端设置一个安全层来授予访问每个端点的权限(我不知道我们是需要从API网关还是像
@PreAuthorize(“hasRole('ROLE\u EMPLOYER')或hasRole('ROLE\u ADMIN')”)
@Secured({ROLE\u ADMIN})

基本上,我也需要在AWSAPI网关中防止某些用户使用某些端点

到目前为止,我在用户池中创建了一个用户,并将其添加到组中

 // Getting the AWSCognitoIdentityProviderClientBuilder with Credentials
AWSCognitoIdentityProvider cognitoClient = amazonClientService.getAmazonCognitoIdentityClient();

SignUpRequest signUpRequest =
    new SignUpRequest()
        .withClientId(clientId)
        .withPassword(user.getPassword())
        .withUsername(user.getEmail())
        .withUserAttributes(new AttributeType().withName("email").withValue(user.getEmail()));

SignUpResult createUserResult = cognitoClient.signUp(signUpRequest);

AdminAddUserToGroupRequest addUserToGroupRequest =
    new AdminAddUserToGroupRequest()
        .withGroupName(UserGroup.USER_GROUP)
        .withUsername(user.getEmail())
        .withUserPoolId(userPoolId);

AdminAddUserToGroupResult adminAddUserToGroupResult =
    cognitoClient.adminAddUserToGroup(addUserToGroupRequest);

//  userRepository.save(user);
我想知道如何在AWS中创建基于角色的用户管理?我的方法正确吗?我提前提到了谢谢