Role

With this resource, you can created 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
        {
            EnforcePolicies = true,
            Identifier = "my-resource-server-identifier",
            Scopes = 
            {
                new Auth0.Inputs.ResourceServerScopeArgs
                {
                    Description = "read something",
                    Value = "read:something",
                },
            },
            SigningAlg = "RS256",
            SkipConsentForVerifiableFirstPartyClients = true,
            TokenLifetime = 86400,
        });
        var myRole = new Auth0.Role("myRole", new Auth0.RoleArgs
        {
            Description = "Role Description...",
            Permissions = 
            {
                new Auth0.Inputs.RolePermissionArgs
                {
                    Name = "read:something",
                    ResourceServerIdentifier = myResourceServer.Identifier,
                },
            },
        });
        var myUser = new Auth0.User("myUser", new Auth0.UserArgs
        {
            ConnectionName = "Username-Password-Authentication",
            Email = "test@test.com",
            Nickname = "testnick",
            Password = "passpass$12$12",
            Roles = 
            {
                myRole.Id,
            },
            UserId = "auth0|1234567890",
            Username = "testnick",
        });
    }

}
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{
			EnforcePolicies: pulumi.Bool(true),
			Identifier:      pulumi.String("my-resource-server-identifier"),
			Scopes: auth0.ResourceServerScopeArray{
				&auth0.ResourceServerScopeArgs{
					Description: pulumi.String("read something"),
					Value:       pulumi.String("read:something"),
				},
			},
			SigningAlg: pulumi.String("RS256"),
			SkipConsentForVerifiableFirstPartyClients: pulumi.Bool(true),
			TokenLifetime: pulumi.Int(86400),
		})
		if err != nil {
			return err
		}
		myRole, err := auth0.NewRole(ctx, "myRole", &auth0.RoleArgs{
			Description: pulumi.String("Role Description..."),
			Permissions: auth0.RolePermissionArray{
				&auth0.RolePermissionArgs{
					Name:                     pulumi.String("read:something"),
					ResourceServerIdentifier: myResourceServer.Identifier,
				},
			},
		})
		if err != nil {
			return err
		}
		_, err = auth0.NewUser(ctx, "myUser", &auth0.UserArgs{
			ConnectionName: pulumi.String("Username-Password-Authentication"),
			Email:          pulumi.String("test@test.com"),
			Nickname:       pulumi.String("testnick"),
			Password:       pulumi.String(fmt.Sprintf("%v%v%v%v%v", "passpass", "$", "12", "$", "12")),
			Roles: pulumi.StringArray{
				myRole.ID(),
			},
			UserId:   pulumi.String("auth0|1234567890"),
			Username: pulumi.String("testnick"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_auth0 as auth0

my_resource_server = auth0.ResourceServer("myResourceServer",
    enforce_policies=True,
    identifier="my-resource-server-identifier",
    scopes=[auth0.ResourceServerScopeArgs(
        description="read something",
        value="read:something",
    )],
    signing_alg="RS256",
    skip_consent_for_verifiable_first_party_clients=True,
    token_lifetime=86400)
my_role = auth0.Role("myRole",
    description="Role Description...",
    permissions=[auth0.RolePermissionArgs(
        name="read:something",
        resource_server_identifier=my_resource_server.identifier,
    )])
my_user = auth0.User("myUser",
    connection_name="Username-Password-Authentication",
    email="test@test.com",
    nickname="testnick",
    password="passpass$12$12",
    roles=[my_role.id],
    user_id="auth0|1234567890",
    username="testnick")
import * as pulumi from "@pulumi/pulumi";
import * as auth0 from "@pulumi/auth0";

const myResourceServer = new auth0.ResourceServer("my_resource_server", {
    enforcePolicies: true,
    identifier: "my-resource-server-identifier",
    scopes: [{
        description: "read something",
        value: "read:something",
    }],
    signingAlg: "RS256",
    skipConsentForVerifiableFirstPartyClients: true,
    tokenLifetime: 86400,
});
const myRole = new auth0.Role("my_role", {
    description: "Role Description...",
    permissions: [{
        name: "read:something",
        resourceServerIdentifier: myResourceServer.identifier,
    }],
});
const myUser = new auth0.User("my_user", {
    connectionName: "Username-Password-Authentication",
    email: "test@test.com",
    nickname: "testnick",
    password: "passpass$12$12",
    roles: [myRole.id],
    userId: "auth0|1234567890",
    username: "testnick",
});

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)
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.

Role Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model 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<RolePermissionArgs>
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 []RolePermission
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 RolePermissionArgs[]
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[RolePermissionArgs]
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 str
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)
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.

The following state arguments are supported:

Description string
String. Description of the role.
Name string
String. Name for this role.
Permissions List<RolePermissionArgs>
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 []RolePermission
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 RolePermissionArgs[]
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[RolePermissionArgs]
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).
ResourceServerIdentifier string
String. Unique identifier for the resource server.
Name string
String. Name of the permission (scope).
ResourceServerIdentifier string
String. Unique identifier for the resource server.
name string
String. Name of the permission (scope).
resourceServerIdentifier string
String. Unique identifier for the resource server.
name str
String. Name of the permission (scope).
resource_server_identifier str
String. Unique identifier for the resource server.

Package Details

Repository
https://github.com/pulumi/pulumi-auth0
License
Apache-2.0
Notes
This Pulumi package is based on the auth0 Terraform Provider.