Skip to main content

Identity Governance is available only with Teleport Enterprise. Start your free trial.

Start your free trial

Granting Resource Access with Access Lists

Report an Issue

This guide shows how to use Access Lists to grant access to the resources in your Teleport cluster. You will create three Access Lists:

  • A standing Access List that gives the members of an IdP group access to a database whenever they log in.
  • A just-in-time Access List that lets the members of another IdP group request temporary access to the same database, with approval from a third group.
  • A custom Access List that assigns an existing role to a user.
Workshop environment

This guide uses the out-of-the-box setup of the workshop environment.

How it works​

To simplify access configuration, Teleport provides guided flows to create the following types of Access Lists in the Web UI. Note that Access Lists can be created and managed via Terraform, CLI or API as well.

  • Standing Access List. Members get standing access to the selected resources. Teleport auto-creates the roles.
  • Just-in-Time Access List. Members get permission to request access to the selected resources, owners - to review the requests. Teleport auto-creates the roles.
  • Custom Access List. Members get the roles you grant explicitly.

Members of an Access List can be users or other Access Lists. When you add an IdP group's Access List as a member, the group's members inherit the access through nesting, and the IdP keeps managing who is in the group.

Prerequisites​

  • A Teleport Enterprise cluster with Identity Governance.
  • A Teleport user with the editor role.
  • A database enrolled in Teleport, with labels you can select it by.
  • Access Lists for your IdP groups, for example from the Okta, Entra ID, or SCIM integration. This guide uses three groups:
    • dba: gets standing access to the database.
    • readonly: requests just-in-time access to the database.
    • admins: approves database Access Requests.
Workshop environment
  • Sign in to https://teleport.localhost:3080 with the default Duo login and choose Andrew Admin. This user has the editor role.
  • The cluster has a PostgreSQL database labeled env: docker.
  • The Duo simulator has three users, Andrew Admin, Randy Reviewer, and Roger Requester, with @duo.example.com logins. Andrew is in admins and dba, Randy is in admins, and Roger is in readonly. The simulator pushes the groups to the SCIM Access Lists admins, readonly, and dba.
  • Members of readonly, such as Roger, can't see or request access to the database.
Infrastructure as code

At the end of each flow, you can choose to create Access Lists with Terraform instead of in web UI directly. You can see details on how to use Terraform with a Teleport cluster in the Teleport Terraform provider docs.

Terraform creates Access Lists of the "static" type which don't support periodic reviews.

Each step below also shows equivalent Terraform configuration. To apply it, save the provider configuration as main.tf in an empty directory:

terraform {
  required_providers {
    teleport = {
      source  = "terraform.releases.teleport.dev/gravitational/teleport"
      version = "~> 19.0"
    }
  }
}

# Credentials come from the environment variables that
# `tctl terraform env` sets.
provider "teleport" {
  addr = "teleport.localhost:3080"
}

Sign in as Andrew Admin, get temporary credentials for the provider, and initialize the directory:

tsh login --proxy=teleport.localhost:3080
eval "$(tctl terraform env)"
terraform init

Then save each step's configuration in the same directory and run terraform apply.

Step 1/3. Grant standing access to a database​

In this step you will give the members of the dba group permanent access to the database whenever they log in.

In the Teleport Web UI, go to Create New Access List and follow the Standing Access guided flow to create a "Database Access" Access List that gives access to databases matching env: docker labels as the postgres database user. Pick dba group as a member and [email protected] as the owner.

Teleport creates a role that allows access to the matching databases and grants it to the Access List.

Terraform
# Allows connecting to databases labeled env: docker as the postgres user.
resource "teleport_role" "database_access" {
  version = "v7"
  metadata = {
    name = "database-access"
  }
  spec = {
    allow = {
      db_labels = {
        env = ["docker"]
      }
      db_users = ["postgres"]
      db_names = ["postgres"]
    }
  }
}

resource "teleport_access_list" "database_access" {
  header = {
    version = "v1"
    metadata = {
      name = "database-access"
    }
  }
  spec = {
    type  = "static"
    title = "Database Access"
    owners = [
      {
        name            = "[email protected]"
        membership_kind = 1 # user
      }
    ]
    grants = {
      roles = [teleport_role.database_access.metadata.name]
    }
  }
}

# The dba SCIM Access List is a member, so the group's members inherit
# the grants.
resource "teleport_access_list_member" "database_access_dba" {
  header = {
    version = "v1"
    metadata = {
      name = "dba"
    }
  }
  spec = {
    access_list     = teleport_access_list.database_access.id
    membership_kind = 2 # Access List
  }
}

To verify, sign out and log in as Andrew Admin again. Access List grants apply at login. The database has a Connect button, and the access stays in place as long as Andrew is in the dba group.

Step 2/3. Grant just-in-time access to a database​

In this step you will let the members of the readonly group request temporary access to the same database, with the members of admins reviewing their requests.

Sign in as Andrew Admin, go to Create New Access List and follow the Just-in-Time Access guided flow to create a "Database Access Requester" Access List that lets members request access to databases matching env: docker labels as the postgres database user. Pick readonly group as a member and admins group as the owner.

Teleport creates three roles: one that grants access to the database, one that lets members request it, and one that lets owners review those requests.

Terraform
# Members get the database-access role from step 1 only through an approved
# Access Request.

# Lets members request the access role.
resource "teleport_role" "database_access_requester" {
  version = "v7"
  metadata = {
    name = "database-access-requester"
  }
  spec = {
    allow = {
      request = {
        search_as_roles = [teleport_role.database_access.metadata.name]
      }
    }
  }
}

# Lets owners review requests for the access role.
resource "teleport_role" "database_access_reviewer" {
  version = "v7"
  metadata = {
    name = "database-access-reviewer"
  }
  spec = {
    allow = {
      review_requests = {
        roles            = [teleport_role.database_access.metadata.name]
        preview_as_roles = [teleport_role.database_access.metadata.name]
      }
    }
  }
}

resource "teleport_access_list" "database_access_requester" {
  header = {
    version = "v1"
    metadata = {
      name = "database-access-requester"
    }
  }
  spec = {
    type  = "static"
    title = "Database Access Requester"
    # The admins SCIM Access List owns the list, so the group's members can
    # review requests.
    owners = [
      {
        name            = "admins"
        membership_kind = 2 # Access List
      }
    ]
    grants = {
      roles = [teleport_role.database_access_requester.metadata.name]
    }
    owner_grants = {
      roles = [teleport_role.database_access_reviewer.metadata.name]
    }
  }
}

resource "teleport_access_list_member" "database_access_requester_readonly" {
  header = {
    version = "v1"
    metadata = {
      name = "readonly"
    }
  }
  spec = {
    access_list     = teleport_access_list.database_access_requester.id
    membership_kind = 2 # Access List
  }
}

To verify:

  1. Log in as Roger Requester. The database now appears in the resource list as requestable. Submit an Access Request for it.
  2. Log in as Randy Reviewer and approve the request on the Access Requests page.
  3. Log in as Roger again, open the approved request, and click Assume Roles. You can now connect to the database. Unlike the standing access of the dba members, Roger's access ends when the request expires or the session ends.

Step 3/3. Assign an existing role with a custom Access List​

Use the Custom flow to create an Access List that grants roles that already exist. In this step you will give Roger the preset auditor role for a compliance review, so that Roger can read the audit log and session recordings.

Sign in as Andrew Admin, go to Create New Access List and click Use Custom Form Instead to create an Access List that grants the auditor role to its members. Pick [email protected] as a member and [email protected] as the owner.

Terraform
resource "teleport_access_list" "compliance_auditors" {
  header = {
    version = "v1"
    metadata = {
      name = "compliance-auditors"
    }
  }
  spec = {
    type  = "static"
    title = "Compliance auditors"
    owners = [
      {
        name            = "[email protected]"
        membership_kind = 1 # user
      }
    ]
    # The preset auditor role already exists, so the list only grants it.
    grants = {
      roles = ["auditor"]
    }
  }
}

resource "teleport_access_list_member" "compliance_auditors_roger" {
  header = {
    version = "v1"
    metadata = {
      name = "[email protected]"
    }
  }
  spec = {
    access_list     = teleport_access_list.compliance_auditors.id
    membership_kind = 1 # user
  }
}

To verify, log in as Roger Requester. The Audit section of the sidebar now shows the audit log and the session recordings.

When the review is over, remove Roger from the list. Roger loses the auditor role at the next login. You can also add members to an Access List with a TTL so their membership automatically expires.

Further reading​