Skip to content
v2.275.0

ResourceServerScope Class ​

A scope for ResourceServer.

Example ​

ts
const pool = new cognito.UserPool(this, 'Pool');

const readOnlyScope = new cognito.ResourceServerScope({ scopeName: 'read', scopeDescription: 'Read-only access' });
const fullAccessScope = new cognito.ResourceServerScope({ scopeName: '*', scopeDescription: 'Full access' });

const userServer = pool.addResourceServer('ResourceServer', {
  identifier: 'users',
  scopes: [ readOnlyScope, fullAccessScope ],
});

const readOnlyClient = pool.addClient('read-only-client', {
  // ...
  oAuth: {
    // ...
    scopes: [ cognito.OAuthScope.resourceServer(userServer, readOnlyScope) ],
  },
});

const fullAccessClient = pool.addClient('full-access-client', {
  // ...
  oAuth: {
    // ...
    scopes: [ cognito.OAuthScope.resourceServer(userServer, fullAccessScope) ],
  },
});
python
pool = cognito.UserPool(self, "Pool")

read_only_scope = cognito.ResourceServerScope(scope_name="read", scope_description="Read-only access")
full_access_scope = cognito.ResourceServerScope(scope_name="*", scope_description="Full access")

user_server = pool.add_resource_server("ResourceServer",
    identifier="users",
    scopes=[read_only_scope, full_access_scope]
)

read_only_client = pool.add_client("read-only-client",
    # ...
    o_auth=cognito.OAuthSettings(
        # ...
        scopes=[cognito.OAuthScope.resource_server(user_server, read_only_scope)]
    )
)

full_access_client = pool.add_client("full-access-client",
    # ...
    o_auth=cognito.OAuthSettings(
        # ...
        scopes=[cognito.OAuthScope.resource_server(user_server, full_access_scope)]
    )
)
java
UserPool pool = new UserPool(this, "Pool");

ResourceServerScope readOnlyScope = ResourceServerScope.Builder.create().scopeName("read").scopeDescription("Read-only access").build();
ResourceServerScope fullAccessScope = ResourceServerScope.Builder.create().scopeName("*").scopeDescription("Full access").build();

UserPoolResourceServer userServer = pool.addResourceServer("ResourceServer", UserPoolResourceServerOptions.builder()
        .identifier("users")
        .scopes(List.of(readOnlyScope, fullAccessScope))
        .build());

UserPoolClient readOnlyClient = pool.addClient("read-only-client", UserPoolClientOptions.builder()
        // ...
        .oAuth(OAuthSettings.builder()
                // ...
                .scopes(List.of(OAuthScope.resourceServer(userServer, readOnlyScope)))
                .build())
        .build());

UserPoolClient fullAccessClient = pool.addClient("full-access-client", UserPoolClientOptions.builder()
        // ...
        .oAuth(OAuthSettings.builder()
                // ...
                .scopes(List.of(OAuthScope.resourceServer(userServer, fullAccessScope)))
                .build())
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
var pool = new UserPool(this, "Pool");

var readOnlyScope = new ResourceServerScope(new ResourceServerScopeProps { ScopeName = "read", ScopeDescription = "Read-only access" });
var fullAccessScope = new ResourceServerScope(new ResourceServerScopeProps { ScopeName = "*", ScopeDescription = "Full access" });

var userServer = pool.AddResourceServer("ResourceServer", new UserPoolResourceServerOptions {
    Identifier = "users",
    Scopes = new [] { readOnlyScope, fullAccessScope }
});

var readOnlyClient = pool.AddClient("read-only-client", new UserPoolClientOptions {
    // ...
    OAuth = new OAuthSettings {
        // ...
        Scopes = new [] { OAuthScope.ResourceServer(userServer, readOnlyScope) }
    }
});

var fullAccessClient = pool.AddClient("full-access-client", new UserPoolClientOptions {
    // ...
    OAuth = new OAuthSettings {
        // ...
        Scopes = new [] { OAuthScope.ResourceServer(userServer, fullAccessScope) }
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
pool := cognito.NewUserPool(this, jsii.String("Pool"))

readOnlyScope := cognito.NewResourceServerScope(&ResourceServerScopeProps{
	ScopeName: jsii.String("read"),
	ScopeDescription: jsii.String("Read-only access"),
})
fullAccessScope := cognito.NewResourceServerScope(&ResourceServerScopeProps{
	ScopeName: jsii.String("*"),
	ScopeDescription: jsii.String("Full access"),
})

userServer := pool.addResourceServer(jsii.String("ResourceServer"), &UserPoolResourceServerOptions{
	Identifier: jsii.String("users"),
	Scopes: []ResourceServerScope{
		readOnlyScope,
		fullAccessScope,
	},
})

readOnlyClient := pool.addClient(jsii.String("read-only-client"), &UserPoolClientOptions{
	// ...
	OAuth: &OAuthSettings{
		// ...
		Scopes: []OAuthScope{
			cognito.OAuthScope_ResourceServer(userServer, readOnlyScope),
		},
	},
})

fullAccessClient := pool.addClient(jsii.String("full-access-client"), &UserPoolClientOptions{
	// ...
	OAuth: &OAuthSettings{
		// ...
		Scopes: []OAuthScope{
			cognito.OAuthScope_*ResourceServer(userServer, fullAccessScope),
		},
	},
})

Initializer ​

ts
new ResourceServerScope(props: ResourceServerScopeProps)
python
ResourceServerScope(props: ResourceServerScopeProps)
java
new ResourceServerScope(ResourceServerScopeProps props)
csharp
new ResourceServerScope(ResourceServerScopeProps props)
go
NewResourceServerScope(Props ResourceServerScopeProps)

Properties ​

scopeDescriptionstringscope_descriptionstrscopeDescriptionStringScopeDescriptionstringScopeDescription*string#
A description of the scope.
scopeNamestringscope_namestrscopeNameStringScopeNamestringScopeName*string#
The name of the scope.