Configuring Regular Expression to Extract Policy Username

Example configurations for user extraction with regular expressions

Configuring Regular Expression to Extract Policy Username

Cloud Protect Cloud Function exposes USERNAME_REGEX configuration to allow extraction of policy username from user in the request.

  • USERNAME_REGEX Cloud Function Environment configuration

    The USERNAME_REGEX environment variable can be set to contain regular expression with one capturing group. This group is used to extract the username. Examples below show different regular expression values and the resulting policy user.

USERNAME_REGEX

User in the request

Effective Policy User

Not Set

user@domain.com

user@domain.com

service-account-user@project-id.iam.gserviceaccount.com

service-account-user@project-id.iam.gserviceaccount.com

^(.*)@.*$

service-account-user@project-id.iam.gserviceaccount.com

service-account-user

user@domain.com

user


Last modified : March 31, 2026