Auth0
Role
With this resource, you can create and manage collections of permissions that can be assigned to users, which are otherwise known as roles. Permissions (scopes) are created on auth0_resource_server, then associated with roles and optionally, users using this resource.
Example Usage
using Pulumi;
using Auth0 = Pulumi.Auth0;
class MyStack : Stack
{
public MyStack()
{
var myResourceServer = new Auth0.ResourceServer("myResourceServer", new Auth0.ResourceServerArgs
{
Identifier = "my-resource-server-identifier",
SigningAlg = "RS256",
TokenLifetime = 86400,
SkipConsentForVerifiableFirstPartyClients = true,
EnforcePolicies = true,
Scopes =
{
new Auth0.Inputs.ResourceServerScopeArgs
{
Value = "read:something",
Description = "read something",
},
},
});
var myRole = new Auth0.Role("myRole", new Auth0.RoleArgs
{
Description = "Role Description...",
Permissions =
{
new Auth0.Inputs.RolePermissionArgs
{
ResourceServerIdentifier = myResourceServer.Identifier,
Name = "read:something",
},
},
});
var myUser = new Auth0.User("myUser", new Auth0.UserArgs
{
ConnectionName = "Username-Password-Authentication",
UserId = "auth0|1234567890",
Email = "test@test.com",
Password = "passpass$12$12",
Nickname = "testnick",
Username = "testnick",
Roles =
{
myRole.Id,
},
});
}
}
package main
import (
"fmt"
"github.com/pulumi/pulumi-auth0/sdk/v2/go/auth0"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
myResourceServer, err := auth0.NewResourceServer(ctx, "myResourceServer", &auth0.ResourceServerArgs{
Identifier: pulumi.String("my-resource-server-identifier"),
SigningAlg: pulumi.String("RS256"),
TokenLifetime: pulumi.Int(86400),
SkipConsentForVerifiableFirstPartyClients: pulumi.Bool(true),
EnforcePolicies: pulumi.Bool(true),
Scopes: ResourceServerScopeArray{
&ResourceServerScopeArgs{
Value: pulumi.String("read:something"),
Description: pulumi.String("read something"),
},
},
})
if err != nil {
return err
}
myRole, err := auth0.NewRole(ctx, "myRole", &auth0.RoleArgs{
Description: pulumi.String("Role Description..."),
Permissions: RolePermissionArray{
&RolePermissionArgs{
ResourceServerIdentifier: myResourceServer.Identifier,
Name: pulumi.String("read:something"),
},
},
})
if err != nil {
return err
}
_, err = auth0.NewUser(ctx, "myUser", &auth0.UserArgs{
ConnectionName: pulumi.String("Username-Password-Authentication"),
UserId: pulumi.String("auth0|1234567890"),
Email: pulumi.String("test@test.com"),
Password: pulumi.String(fmt.Sprintf("%v%v%v%v%v", "passpass", "$", "12", "$", "12")),
Nickname: pulumi.String("testnick"),
Username: pulumi.String("testnick"),
Roles: pulumi.StringArray{
myRole.ID(),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var myResourceServer = new ResourceServer("myResourceServer", ResourceServerArgs.builder()
.identifier("my-resource-server-identifier")
.signingAlg("RS256")
.tokenLifetime(86400)
.skipConsentForVerifiableFirstPartyClients(true)
.enforcePolicies(true)
.scopes(ResourceServerScopeArgs.builder()
.value("read:something")
.description("read something")
.build())
.build());
var myRole = new Role("myRole", RoleArgs.builder()
.description("Role Description...")
.permissions(RolePermissionArgs.builder()
.resourceServerIdentifier(myResourceServer.identifier())
.name("read:something")
.build())
.build());
var myUser = new User("myUser", UserArgs.builder()
.connectionName("Username-Password-Authentication")
.userId("auth0|1234567890")
.email("test@test.com")
.password("passpass$12$12")
.nickname("testnick")
.username("testnick")
.roles(myRole.id())
.build());
}
}
import pulumi
import pulumi_auth0 as auth0
my_resource_server = auth0.ResourceServer("myResourceServer",
identifier="my-resource-server-identifier",
signing_alg="RS256",
token_lifetime=86400,
skip_consent_for_verifiable_first_party_clients=True,
enforce_policies=True,
scopes=[auth0.ResourceServerScopeArgs(
value="read:something",
description="read something",
)])
my_role = auth0.Role("myRole",
description="Role Description...",
permissions=[auth0.RolePermissionArgs(
resource_server_identifier=my_resource_server.identifier,
name="read:something",
)])
my_user = auth0.User("myUser",
connection_name="Username-Password-Authentication",
user_id="auth0|1234567890",
email="test@test.com",
password="passpass$12$12",
nickname="testnick",
username="testnick",
roles=[my_role.id])
import * as pulumi from "@pulumi/pulumi";
import * as auth0 from "@pulumi/auth0";
const myResourceServer = new auth0.ResourceServer("myResourceServer", {
identifier: "my-resource-server-identifier",
signingAlg: "RS256",
tokenLifetime: 86400,
skipConsentForVerifiableFirstPartyClients: true,
enforcePolicies: true,
scopes: [{
value: "read:something",
description: "read something",
}],
});
const myRole = new auth0.Role("myRole", {
description: "Role Description...",
permissions: [{
resourceServerIdentifier: myResourceServer.identifier,
name: "read:something",
}],
});
const myUser = new auth0.User("myUser", {
connectionName: "Username-Password-Authentication",
userId: "auth0|1234567890",
email: "test@test.com",
password: `passpass$12$12`,
nickname: "testnick",
username: "testnick",
roles: [myRole.id],
});
resources:
myResourceServer:
type: auth0:ResourceServer
properties:
identifier: my-resource-server-identifier
signingAlg: RS256
tokenLifetime: 86400
skipConsentForVerifiableFirstPartyClients: true
enforcePolicies: true
scopes:
- value: read:something
description: read something
myUser:
type: auth0:User
properties:
connectionName: Username-Password-Authentication
userId: auth0|1234567890
email: test@test.com
password: passpass$12$12
nickname: testnick
username: testnick
roles:
- ${myRole.id}
myRole:
type: auth0:Role
properties:
description: Role Description...
permissions:
- resourceServerIdentifier: ${myResourceServer.identifier}
name: read:something
Create a Role Resource
new Role(name: string, args?: RoleArgs, opts?: CustomResourceOptions);
@overload
def Role(resource_name: str,
opts: Optional[ResourceOptions] = None,
description: Optional[str] = None,
name: Optional[str] = None,
permissions: Optional[Sequence[RolePermissionArgs]] = None)
@overload
def Role(resource_name: str,
args: Optional[RoleArgs] = None,
opts: Optional[ResourceOptions] = None)
func NewRole(ctx *Context, name string, args *RoleArgs, opts ...ResourceOption) (*Role, error)
public Role(string name, RoleArgs? args = null, CustomResourceOptions? opts = null)
type: auth0:Role
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RoleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args RoleArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args RoleArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RoleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args RoleArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Role Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The Role resource accepts the following input properties:
- Description string
String. Description of the role.
- Name string
String. Name for this role.
- Permissions
List<Role
Permission Args> Set(Resource). Configuration settings for permissions (scopes) attached to the role. For details, see Permissions.
- Description string
String. Description of the role.
- Name string
String. Name for this role.
- Permissions
[]Role
Permission Args Set(Resource). Configuration settings for permissions (scopes) attached to the role. For details, see Permissions.
- description String
String. Description of the role.
- name String
String. Name for this role.
- permissions
List<Role
Permission Args> Set(Resource). Configuration settings for permissions (scopes) attached to the role. For details, see Permissions.
- description string
String. Description of the role.
- name string
String. Name for this role.
- permissions
Role
Permission Args[] Set(Resource). Configuration settings for permissions (scopes) attached to the role. For details, see Permissions.
- description str
String. Description of the role.
- name str
String. Name for this role.
- permissions
Sequence[Role
Permission Args] Set(Resource). Configuration settings for permissions (scopes) attached to the role. For details, see Permissions.
- description String
String. Description of the role.
- name String
String. Name for this role.
- permissions List<Property Map>
Set(Resource). Configuration settings for permissions (scopes) attached to the role. For details, see Permissions.
Outputs
All input properties are implicitly available as output properties. Additionally, the Role resource produces the following output properties:
- Id string
The provider-assigned unique ID for this managed resource.
- Id string
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
- id string
The provider-assigned unique ID for this managed resource.
- id str
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
Look up an Existing Role Resource
Get an existing Role resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: RoleState, opts?: CustomResourceOptions): Role
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
description: Optional[str] = None,
name: Optional[str] = None,
permissions: Optional[Sequence[RolePermissionArgs]] = None) -> Role
func GetRole(ctx *Context, name string, id IDInput, state *RoleState, opts ...ResourceOption) (*Role, error)
public static Role Get(string name, Input<string> id, RoleState? state, CustomResourceOptions? opts = null)
public static Role get(String name, Output<String> id, RoleState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Description string
String. Description of the role.
- Name string
String. Name for this role.
- Permissions
List<Role
Permission Args> Set(Resource). Configuration settings for permissions (scopes) attached to the role. For details, see Permissions.
- Description string
String. Description of the role.
- Name string
String. Name for this role.
- Permissions
[]Role
Permission Args Set(Resource). Configuration settings for permissions (scopes) attached to the role. For details, see Permissions.
- description String
String. Description of the role.
- name String
String. Name for this role.
- permissions
List<Role
Permission Args> Set(Resource). Configuration settings for permissions (scopes) attached to the role. For details, see Permissions.
- description string
String. Description of the role.
- name string
String. Name for this role.
- permissions
Role
Permission Args[] Set(Resource). Configuration settings for permissions (scopes) attached to the role. For details, see Permissions.
- description str
String. Description of the role.
- name str
String. Name for this role.
- permissions
Sequence[Role
Permission Args] Set(Resource). Configuration settings for permissions (scopes) attached to the role. For details, see Permissions.
- description String
String. Description of the role.
- name String
String. Name for this role.
- permissions List<Property Map>
Set(Resource). Configuration settings for permissions (scopes) attached to the role. For details, see Permissions.
Supporting Types
RolePermission
- Name string
String. Name of the permission (scope).
- Resource
Server stringIdentifier String. Unique identifier for the resource server.
- Name string
String. Name of the permission (scope).
- Resource
Server stringIdentifier String. Unique identifier for the resource server.
- name String
String. Name of the permission (scope).
- resource
Server StringIdentifier String. Unique identifier for the resource server.
- name string
String. Name of the permission (scope).
- resource
Server stringIdentifier String. Unique identifier for the resource server.
- name str
String. Name of the permission (scope).
- resource_
server_ stridentifier String. Unique identifier for the resource server.
- name String
String. Name of the permission (scope).
- resource
Server StringIdentifier String. Unique identifier for the resource server.
Import
Existing roles can be imported using their id, e.g.
$ pulumi import auth0:index/role:Role my_role XXXXXXXXXXXXXXXXXXXXXXX
Package Details
- Repository
- https://github.com/pulumi/pulumi-auth0
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
auth0
Terraform Provider.