πRequest Routing
Last updated
Last updated
Request routing allows you to limit and direct just-in-time access requests, based on who is making the request and which resource is requested.
Request Routing requires a pro-tier P0 subscription.
To use request routing, go to p0.app and navigate to "Routing". Saving a routing configuration here will configure your organization to use routed approvals, rather than default approvals.
When working with Request Routing directly, you should use this reference page for specific definitions of how to format your request properly. This feature of p0 is powerful and customizable, and that's why we've made it accessible via a full API for those who want to use it that way.
We call a collection of routing rules a Workflow, and when you want to make changes to the way your requests are routed in p0 (such as, sending engineers' request to their managers, or restricting access to a particular prod resource to a small group), you do so by submitting a new Workflow.
Keep in mind that you only have one Workflow active at any given time, but that one Workflow can have as many individual routing rules as you want. You do not need to separate out different rule types or anything like that.
Here's an example Workflow that you can copy into your app as a starting point:
The core of workflows are the rules, so let's break them down.
The first part of a rule is a "requestor", which matches who makes the request. There are four types of requestors you can choose from:
This will match all requestors. Useful for global rules like fall-back restrictions of sensitive resources.
This will only allow this rule to match if another separate rule also matches (and otherwise acts like an "any" rule). For more information, What Are "Some" Rules?.
This rule will match any requestor that is a member of a group in your IdP. Currently, this supports Google Workspace, Microsoft Entra ID, and Okta.
id: For Google Workspace, this is the group email address (ie, engineering@yourco.com). For Entra, this is the Entra ID group's UUID. For Okta, this is the group ID found in the URL of the group's page in the admin console. See Okta docs.
label: This is any friendly human-readable name you like, although P0 suggests using the same name as displayed in your directory.
directory: For Google Workspace this is "workspace", for Okta this is "okta", and for Entra ID, this is "azure-ad".
This rule will match only a specific user, as identified by their email address.
The second part of a routing rule is the resource this rule should apply to.
This will match all resources. This is useful, for instance, when you want to route access for a particular user, regardless of what resource or service they are looking to access.
This will only allow this rule to match if another separate rule also matches (and otherwise acts like an "any" rule). For more information, What Are "Some" Rules?.
This rule will match a specific type of access request. For instance, maybe you want to create a rule that routes all AWS requests to your DevOps team. Or you want to restrict access to GCP to only a select group.
service: For GCloud, "gcloud", for AWS, "aws", and for Snowflake, "snowflake".
filters (Optional): Filters allow you to apply the rule only to the service components that match the filtering condition.
Each filter has an access-type
that refers to the type of the requested object. For instance, when "service" is "aws", the filter with access type "policy" will only allow requesting policies whose ARNs match the pattern
.
Note that filters do not affect other access types. For example, if you specify an access-type=permission
filter for service=gcloud
requests, but omit an access-type=role
filter, then roles will be unaffected by the filter, i.e. all roles will remain requestable.
Each filter has three potential properties:
effect - Describes how this filter is applied
keep - This rule will retain objects that match the pattern as requestable
remove - This rule will only retain objects that do not match the pattern
removeAll - This rule disables the object type entirely.
If you want to allow all objects of a type as requestable, omit the filter altogether
key - Describes which property of the object the filter must match; only applies if "effect" is one of "keep" or "remove". For instance, if service=aws
and access-type=permission-set
then the key can be "name" or "arn". If "name", the regex pattern will be matched against the name of permission sets. If "arn", the entire arn is matched.
pattern - A regex pattern used to match against the specified property; only applies if "effect" is one of "keep" or "remove"
Patterns are unanchored. Use line-start (^
) and line-end ($
) markers to anchor patterns.
P0 uses the JavaScript regex dialect.
Valid filter access-type / key combinations are summarized in the below table.
For more detailed information on the filters, see the documentation for AWS and Google Cloud.
aws
tag
<tag key>
Only filters policies and permission sets. AWS managed policies cannot be tagged.
group
name
Filters IAM group names
permission-set
arn | name
Filters Identity Center permission sets
policy
arn
Filters policies with matching ARNs
resource
arn | name | service
Filters resource requests based on the resource ARN, the resource name, or the service the resource belongs to.
azure-ad|okta
group
id | label
Filters directory groups
gcloud
permission
id
Filters IAM permissions
role
id
Filters IAM roles based on full ID (e.g. the ID for "Owner" is roles/owner
)
resource
name | type | full-resource-name
Filters resource requests based on the resource name, resource type, or the full resource name.
snowflake
role
name
Filters roles
k8s
resource
kind | name | namespace
Filters resources
role
name
Filters roles and cluster roles
cluster
name
Filters clusters based on the cluster name specified when installed in P0
Note that filters are not currently available for AWS or GCP resource-level grants, nor for Snowflake SQL grants.
Example that covers each possible access-type in the AWS service:
Exclude all permission sets containing "FullAccess"
Only allow AWS policies and permission sets where the tag "P0Grantable" is equal to the string "true".
Do not allow requesting any AWS groups
The final part of a routing rule is the "approval". Unlike the requestor and resource parts, the approval part is an array of multiple rules, referring to the people/groups/services that can approve (or deny) access requests.
This approval type is analogous to the default approval behavior. This rule routes approvals to the people designated as "Approvers" on the Settings page of your app. The "options" key is optional. You can use it to:
allow the requestor to approve their own requests for this flow with the allowOneParty: true
setting. Defaults to false
.
require the requestor to specify a reason when submitting requests with the requireReason: true
setting. Defaults to false
.
This rule will match any requestor who is a member of a group in your Identity Provider. Currently, p0 supports Google Workspace, Microsoft Entra ID, and Okta.
id: For Google Workspace, this is the group email address (ie, engineering@yourco.com). For Entra ID, this is the Entra ID group's UUID. For Okta, this is the group ID found in the URL of the group's page in the admin console. See Okta docs.
label: This is any friendly human-readable name you like, although P0 suggests using the same name as displayed in your directory. This label will be printed in approval notifications.
directory: For Google Workspace this is "workspace", for Okta this is "okta", and for Entra ID this is "azure-ad".
options: See "p0" section
This rule automatically approves matching access requests for 1 hour.
integration: currently only "pagerduty" is supported. If the requestors in on-call in PagerDuty their requests will be automatically approved.
options: The "options" key is optional. You can use it to require the requestor to specify a reason when submitting requests with the requireReason: true
setting. Defaults to false
.
This rule allows requests to be escalated by creating incident against multiple PagerDuty services using escalate button presented to the requestor. This rule needs to be used along with other approval rules if approval is needed even before the request is escalated.
Integration: currently only "pagerduty" is supported. If the approver is on-call based on the escalation policy of the configured services and the request is escalated, the request can either be approved or denied by the approver.
options: See "p0" section
services: List of PagerDuty service ids against which the incident needs to be triggered.
This rule will deny all requests that match. This supersedes other matching rules: if at least one "deny" rule matches, the request will be denied.
Routing rules can be used for a variety of use cases.
Configure different approvers and different resources for developers and customer-success engineers:
Development AWS account (123456789) allows one-party approvals. Staging AWS account (234567891) allows peer approvals but no one-party approvals. Production AWS account (345678912) requires a manager approver represented by an Okta group. Assumes an AWS Identity Center setup where resource filters allow requesting customer-managed policies in specific AWS accounts, enforced by an ARN match that includes the AWS account ID. Permission sets are implicitly allowed because the permission-set
access type filter is not defined.
Restrict which AWS policies and permission sets can be requested to those for which a tag matches a specific value:
Allow either the requestor's manager or the service owner to approve requests:
Make reason mandatory for AWS requests
These rules are advanced use-case rules that allow you to write essentially "optional" approval rules.
Rules that include a "some" component, either as the resource or the requestor can be chained with other rules that specify those same fields and act as an additional way to get approval.
For instance, you may have a rule that all requests for access to an AWS permission set need to be approved by your Platform Engineering team (defined as a group in your IDP). You can include another rule which has a "Some" resource and matches the requestor (say an engineer in another IDP group called Security Team One) which provides an approver of your Security Management group. In this case, the engineer in Security Team One could request access to an AWS permission set and have it approved by *either* someone on the Platform Engineering Team OR someone in the Security Management group.
This feature is for very advanced use-cases only and is still somewhat experimental, so if you feel like you may need to use it, feel free to reach out to our support team if you need some guidance.