Secret Management Configuration
    • 26 Feb 2025
    • 17 Minutes to read
    • Dark
      Light
    • PDF

    Secret Management Configuration

    • Dark
      Light
    • PDF

    Article summary

    The Secret Management Service is an optional PAA component responsible for integrating with secret stores and providing secrets to other PAA services. Currently, the service supports these use cases:

    • Passwords/secrets for data source connections in the PIP-Operator
    • Passwords for the PDP Authorization Audit Database connection settings
    • REDIS authentication passwords for PAA services
    • A private key for the PDP to sign Authorization Decisions returned as JWTs

    Supported Secret Stores

    Use CaseHashiCorp VaultAWS Secrets ManagerAWS RDS IAMEnvironment VariableText File
    Private Keys
    for PDP JWT signing
    --
    AWS ElastiCache for Redis Passwords----
    Using Secrets for PIP Connections--
    Authorization Database Audit Connection--
    Additional Integrations

    For additional Secret store integrations or use cases, contact PlainID to discuss options.

    Configuring the Secret Management Service

    By default, the Secret Management Service is not included in the PAA deployment. To enable it, add a secretsMgmt section to the values-custom.yaml file and follow the configuration instructions.

    Enabling and Configuring the Service

    After adding to the values-custom.yaml file the secret-mgmt section, set it as enabled: true and define additional configuration parameters, such as ports, logging, and most importantly, secretStore definitions.

    Example:

    secretsMgmt:
      enabled: true
      replicaCount: 1
      command: []
      # Allows you to add any config files to /app/config
      plainIDConfig:
        config.yaml:
          server:
            port: 8080
            # Which IP is allowed to make requests to secret-mgmt
            bindIp: 0.0.0.0
          management:
            port: 8081
          log:
            level: "info" #debug,trace
            format: "json"
            logTo: "console" # rolling, file
          rabbitmq:
            enabled: false
          gin:
            mode: release # debug, release
          # Secret Store configuration
          secretStore:
            - id: fileSecret
              type: File
              isDefault: true
              decoder: Base64
              details:
                path: /app/config/filename.txt
            # Examples below for HashiCorp Vault based Secret Store
    #       - id: vault
    #         type: Vault
    #         isDefault: true
    #         decoder: None # Base64, None
    #         details:
    #           PathPrefix: prefix
    #           defaultPath: vault_
    #           skipVerify: true
    #           url: vault
    #           timeout: 3s
    #           enginePath: custom
    #
    # Authentication method should use a Token
    #         auth:
    #           method: Token # Token, Kubernetes
    #           tokenValue: token
    #           tokenFileName: ${ VAULT_TOKEN }  - instead of token value
    #
    # OR Authentication method should use vault Kubernetes authentication
    #         auth:
    #           method: Kubernetes
    #           path: /var/path-to-file/file.txt
    #           role: secrets-mgmt
    
    # Examples below for Environment Variables based on the Secret Store
    #       - id: ENV_VAR_SECRET
    #          type: Environment
    #          isDefault: false
    #          decoder: Base64
    #          details:
    #            name: ENV_VAR_SECRET
    

    Optional Settings for the Secret Management Service

    SectionParameterValueDescription
    serverport8080The port number that the server listens to for incoming requests.
    serverbindIp0.0.0.0The IP address authorized to make requests to the Secret management service.
    Use 0.0.0.0 to allow connections from every IP address on the local machine
    managementport8081The port number that the management service listens to for incoming requests.
    loglevelinfoThe Application logging level.
    logformatjsonThe Application logging format.
    loglogToconsoleThe logging output destination.
    ginmodereleaseThe mode that Gin (the HTTP framework) should run in.

    Configuring a Secret Store

    The Secret Store retrieves relevant Secrets (e.g., Private Keys). The Secrets Management Service supports various store integrations, allowing multiple stores to be configured for different purposes. The id defined in this configuration identifies the store integration when setting up a Secret's usage. Refer to the specific Secret Stores below to learn more about specific parameters.

    General Store Parameters

    secretStore:
      - id: vault
        type: Vault
        isDefault: true
        Decoder: None # Base64, None
        details:
          defaultPath: vault_
          skipVerify: true
          url: vault
          timeout: 3s
          enginePath: custom
          pathPrefix: prefix
        auth: #by Token or by K8s authentication
          method: Token # Token, Kubernetes
          tokenValue: token
    #    tokenFileName: ${ VAULT_TOKEN } - alternate for token value
    #
    #  auth:
    #    method: Kubernetes
    #    path: /var/path-to-file/file.txt
    #    role: secrets-mgmt
    

    The parameters below are defined under the secretStore section.

    ParameterValueDescription
    idvaultAn identifier for the Secret store
    typeVaultThe type of Secret store, available types:
    - Vault
    - AWSRDSIAMAuth
    - AWSSecretsManager
    - Environment
    - File
    isDefaulttrueIndicates whether this is the default Secret store. If multiple Secret stores are defined, the default store is used for operations that do not specify a specific store. If more than one Secret store is defined as default, or none are defined as default, the first Secret store is used as the default.
    DecodernoneThe decoder used for the Secrets stored in this store. Possible values are:
    - Base64
    - None
    detailsAdditional details related to the Secret store configuration - specific to each store type (see below)
    details.defaultPathvault\_The default path used for accessing the Secrets in this store

    HashiCorp Store

    Configuring a HashiCorp Vault Secret Store

    The following parameters are required to configure the HashiCorp Vault Secret Store:

    ParameterValueDescription
    details.skipVerifytrueIndicates whether to prefix the Secret Store URL with https:// or http://.
    details.urlThe Secret store URL.
    details.timeout3sThe timeout value for connecting to the Secret store.
    details.enginePathsecretSpecifies the root folder in the HashiCorp Vault Engine from which the Secret Management Service should access Secrets.

    Note: When configuring Vault information in the Scope in the Scope Details in the Environment Settings for JWT signing, do not include the enginePath in the Path to Key parameter.
    details.pathPrefixenvironments/productionThe prefix for all paths when accessing Secrets in this store.
    authAuthentication details for accessing the Secret store. Add relevant Attributes based on the auth.method (Kubernetes or Token).
    auth.methodKubernetesThe authentication method used for accessing the Secret store. Available methods:
    - Kubernetes
    - Token
    auth.pathused for KubernetesFile path for the Kubernetes authorization value.
    auth.roleused for KubernetesVault authorization role name.
    auth.tokenValueused for tokenThe token value used for authentication when accessing the Secret store.
    auth.tokenFilePathused for tokenFile path holding the token.

    Environment Variables Store

    Configuring an Environment Variable Secret Store

    The Secret Management Service can also obtain private keys from Environment Variables. To configure a Secret Store that reads private keys from Environment Variables, use the following configuration:

    ParameterValueDescription
    typeEnvironmentSet the type of the Secret store to Environment Variables
    details.nameENV_VAR_SECRETThe name of the Environment Variable from which to obtain the private key

    Sample Configuration

    secretsMgmt:
      ...
      plainIDConfig:
        ...
          # Secret Store configuration
          secretStore:
           - id: ENV_VAR_SECRET
              type: Environment
              isDefault: true
              decoder: Base64
              details:
                name: ENV_VAR_SECRET
    

    Text File Store

    Configuring a Text File Secret Store

    The Secret Management Service can also obtain private keys from text files, to configure a secretStore that reads the private keys from text files, use the following configuration:

    ParameterValueDescription
    typeFileSet the type of the Secret store to text file
    details.path/app/conf/filename.txtThe full path to the file containing the private key

    Sample Configuration

    secretsMgmt:
      ...
      plainIDConfig:
        ...
        # Secret Store configuration
    	secretStore:
    	 - id: fileSecret
    	   type: File
    	   isDefault: true
    	   Decoder: Base64
    	   details:
    	     path: /app/conf/filename.txt
       filename.txt: "BASE64 ENCODED SECRET"
    

    An example use case involves injecting a certificate as a Base64-encoded file into the Secrets Management file. This process typically entails encoding the certificate into Base64 format, including it in the configuration file used for Secrets Management, and securely storing it there. Once stored, the Application or system can reference this certificate as needed. This enables secure access to sensitive information without hardcoding credentials or certificates directly into the application code.

    AWS Secret Manager Store

    AWS Secrets Manager provides secure credential management. Integrating with this store ensures seamless access to sensitive credentials and enables automatic rotation and secure retrieval of secrets. This store supports storing and retrieving secrets, including credentials for external services like Redis.

    Prerequisites for AWS SM

    To integrate with AWS SM, set access permissions that allow the PlainID Secrets Management Service to connect, authenticate, and fetch secrets.
    The best practice is to set up an AWS role with the necessary permissions policy and attach it to the Kubernetes cluster that runs the PlainID Secrets Management Service.

    Set AWS Role - The role assigned to the PAA's Secrets Management Service must grant permission to read the Secret containing the relevant passwords. The following resources and actions must be allowed in the AWS Policy:

    • Action: secretsmanager:BatchGetSecretValue
      Resource: *
    • Action: secretsmanager:GetSecretValue
      Resource: The secret's ARN containing a relevant password, such as a Redis password used for Redis authentication.

    Note: the secretsmanager:BatchGetSecretValue permission must be granted on the * resource; It cannot be granted on specific Secret ARNs. See the BatchGetSecretValue row in this table for more
    information.

    Granting the above permission does not allow reading all Secrets. Each Secret returned by the BatchGetSecretValue API must be explicitly allowed by the secretsmanager:GetSecretValue permission. Therefore, the latter must be granted only on the specific ARN of the relevant secrets required by the PlainID integration (Redis, Data Sources, etc.).

    Check out an AWS example policy that explains the above principle here.

    Example JSON for an AWS Policy

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Sid": "fetchSpecificSecret",
          "Effect": "Allow",
          "Action": ["secretsmanager:GetSecretValue"],
          "Resource": "arn:aws:secretsmanager:us-east-1:123456789012:secret:redis-rotated-pw"
        },
        {
          "Sid": "batchFetchSecrets",
          "Effect": "Allow",
          "Action": ["secretsmanager:BatchGetSecretValue"],
          "Resource": ["*"]
        }
      ]
    }
    

    Configuring the AWS SM Secret Store

    Use the following parameters in your configuration:

    ParameterDescription
    typeSet the type of the secret store to AWS Secrets Manager: AWSSecretsManager.
    details.authSet the authentication for AWS Secrets Manager using the parameters below (see more details below).

    The auth configuration keys are optional. If you are using an AWS Role attached to the K8s pod running the Secrets Management Service this will not be needed.
    details.auth.regionSet the relevant AWS region. You can use an Environment Variable: ${AWS_AUTH_REGION}.
    details.auth.accessKeyIdSet the access key ID. You can use an Environment Variable: ${AWS_AUTH_ACCESS_KEY_ID}.
    details.auth.secretAccessKeySet the access key Secret. You can use an Environment Variable: ${AWS_AUTH_SECRET_ACCESS_KEY}.
    serviceAccount.annotations.eks.amazonaws.com/role-arnSet the AWS role defined for the PlainID Secret Management Service.

    This replaces the need for auth configuration.

    Example

    secretsMgmt:
      ...
      plainIDConfig:
       ...
        # Secret Store configuration
    	secretStore:
    	 - id: AWS_SM_STORE
          type: AWSSecretsManager
          isDefault: false
          details:
             auth:
                region: ${AWS_AUTH_REGION}
                accessKeyId: ${AWS_AUTH_ACCESS_KEY_ID}
                secretAccessKey: ${AWS_AUTH_SECRET_ACCESS_KEY}
    

    AWS RDS IAM Authentication Store

    AWS RDS allows an IAM Authentication flow, replacing regular Database connections with a short lived signed connection token. Enabling IAM-based authentication for RDS and integrating it with the Secrets Management Service ensures seamless access to RDS databases and enhances security by eliminating the need for static passwords.

    Prerequisites

    To enable the integration with AWS RDS IAM Auth, you are required to set access permissions allowing PlainID Secrets Management Service to connect with AWS, authenticate and fetch connection tokens.
    The best practice is to set up an AWS Role with the necessary permissions policy and attach it to the Kubernetes cluster running the PlainID Secrets Management Service.

    Set AWS Role - The role assigned to the PAA's Secrets Management Service must grant permission to use the RDS Authentication. The following resources and actions must be allowed in the AWS Policy:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": ["rds-db:connect"],
          "Resource": ["arn:aws:rds-db:<region>:<account>:dbuser:<cluster-resource-id>/<database-user-name>"]
        }
      ]
    }
    

    Define RDS IAM Grants - Follow these steps to prepare your AWS store integration with the PlainID Secret Management Service:

    1. The RDS IAM must be enabled for the relevant RDS cluster.
    2. Create a dedicated user in the RDS database:
    CREATE USER <username> WITH LOGIN;
    GRANT rds_iam TO <username>;
    
    -- Note that from this point if the user existed and had its own password, it will no longer function.
    
    1. Connect to your Database instance using IAM Authentication. Refer to the AWS documentation on this topic.

    Configuring the AWS RDS IAM Auth Secret Store

    The AWS RDS IAM store can be configured in the PlainID Secret Management Service by using the store type AWSRDSIAMAuth.

    In addition, you are required to authenticate to AWS using these parameters:

    ParameterDescription
    typeSet the type of the secret store to AWS Secrets Manager: AWSRDSIAMAuth.
    details.authSet the authentication for AWS RDS IAM using the parameters below (see more details below).

    The auth configuration keys are optional. If you are using an AWS Role attached to the K8s pod running the Secrets Management Service this will not be needed.
    details.auth.regionSet the relevant AWS region. You can use an Environment Variable: ${AWS_AUTH_REGION}.
    details.auth.accessKeyIdSet the access key ID. You can use an Environment Variable: ${AWS_AUTH_ACCESS_KEY_ID}.
    details.auth.secretAccessKeySet the access key Secret. You can use an Environment Variable: ${AWS_AUTH_SECRET_ACCESS_KEY}.
    serviceAccount.annotations.eks.amazonaws.com/role-arnSet the AWS role defined for the PlainID Secret Management Service.

    This replaces the need for auth configuration.

    Example

    secretsMgmt:
      ...
      plainIDConfig:
       ...
        # Secret Store configuration
    	secretStore:
    	 - id: AWS_RDS_IAM_AUTH_STORE
          type: AWSRDSIAMAuth
          isDefault: false
          details:
             auth:
                region: ${AWS_AUTH_REGION}
                accessKeyId: ${AWS_AUTH_ACCESS_KEY_ID}
                secretAccessKey: ${AWS_AUTH_SECRET_ACCESS_KEY}
    

    See more details on how to use this store for RDS connection tokens under Defining RDS Secrets Using the AWS RDS IAM Auth Store

    Secrets Integration Use Cases

    Here are some examples for specific secrets integration use cases supported by the Secrets Management Service and its integration to supported Stores.

    AWS ElastiCache Redis Authentication

    PlainID PAA services use Redis as a data store for various purposes, such as PIP settings, policy metadata, and PDP caching. If you are using an AWS Managed Redis you can leverage PlainID's integration with AWS Secrets Manager to obtain AWS Redis passwords and serve them to the different services. This integration also supports seamless Secret rotation with no downtime or a need to restart the PAA pods, based on the AWS SM Secret rotation and password update in ElastiCache.

    To use this integration pattern you are required to:

    1. Setup an AWS SM integration
    2. Define an AWS Role to allow access from Secrets Management Service to AWS SM
    3. Define the Redis passwords in different services to use secret key from Secrets Management Service

    Configuring AWS SM as a Store

    Follow the configuration steps detailed under AWS Secret Manager Store

    AWS SM Preparations

    To access AWS Secrets Manager, IAM credentials with permissions are required. There are two available methods to grant these permissions:

    • Grant the Secrets Management Service an IAM role directly via EKS, as detailed here (recommended).

    • Configure an AWS Key ID and Secret access key in the Secret Management service’s configuration file.

    Make sure the Redis secret key is granted access permission using the specific Secret ARNs.

    PAA Configurations

    Make sure to add the externalRedis section to your values-custom.yaml and define the connection parameters to use Secrets Management Service with the proper details, such as storeID and secret key. See example below:

    Redis Configuration with secret

    ParameterDescriptionExample Values
    externalRedisThis configuration is not under secretStore but in the general Redis config section.
    .hostHost for external Redis.master.redis-pw-rotation1.0wgi71l.use2.cache.amazonaws.com
    .usernameThe username used for the connection with AWS Secrets Manager.{{store=AWS_SECRETS_MANAGER_STORE,key=redis-rotated-pw,jsonpath=$.username}}
    .passwordThe password used for the connection with AWS Secrets Manager.{{store=AWS_SECRETS_MANAGER_STORE,key=redis-rotated-pw,jsonpath=$.password}}

    PAA services that use Redis get the credentials from the Secret Manager (SM) service do not require special configurations. Once an SM is configured and the externalRedis parameter is defined, all other services seamlessly utilize this configuration.

    Sample Configuration

    secretsMgmt:
      enabled: true
      ...
    
      secretStore:
      - id: AWS_SECRETS_MANAGER_STORE
        type: AWSSecretsManager
        isDefault: false
        details:
          auth:
            region: ${AWS_AUTH_REGION}
            accessKeyId: ${AWS_AUTH_ACCESS_KEY_ID}
            secretAccessKey: ${AWS_AUTH_SECRET_ACCESS_KEY}
    
    serviceAccount:
      annotations:
        eks.amazonaws.com/role-arn: arn:aws:iam::xxx:role/redis-rotating-pw-fetch
    
    redis:
      enabled: false # this capability is supported for external redis in AWS, so the internal redis needs to be disabled
    
    externalRedis:
      port: 6379
      tls: true
      host: "master.redis-pw-rotation1.0wgi71l.use2.cache.amazonaws.com"
    username: |
        "{{store=AWS_SECRETS_MANAGER_STORE,key=redis-rotated-pw,jsonpath=$.username}}"
    password: |
        "{{store=AWS_SECRETS_MANAGER_STORE,key=redis-rotated-pw,jsonpath=$.password}}"
    

    Additional Optional Configurations in PDP, PIP, and Agent Services

    Secret Caching Duration & Refresh In the PAA services (PDP, PIP, and Agent) that use Redis connections, you can define the cache duration for the Redis Secret retrieved from SM. Configure this using the optional environment variable:
    SECRET_MGMT_CLIENT_CACHE_MANAGER_DURATION_SECONDS (default: 3600 seconds).

    Troubleshooting SM Integration Each PAA service connecting to Redis for key retrieval uses the password provided by the SM service. To enable detailed logging for troubleshooting, configure the following settings and set the log level to TRACE:

    • For the agent and pip-operator:
    secretMgmtClient.logging.detailed.enabled = true
    
    • For the runtime:
      "secretsProvider": {
        "logging": {
          "detailed": {
            "enabled": true
          }
        }
      }
    

    Alternatively, users can also use this Environment Variable:

    RT_secretsProvider__logging__detailed__enabled=true
    

    This logging configuration enables the following logs in PAA services during Redis connections:

    logger.detailed("Successfully parsed input: store=" + store);
    logger.detailed("identified as not a pattern, treating as password...");
    



    This guide helps you configure and troubleshoot Redis connections for PAA services, whether using PlainID's Helm deployment or custom Kubernetes setups Leveraging the integration with the Secret Manager Service ensures secure and streamlined access to Redis credentials, while optional configurations and logging enable enhanced flexibility and visibility for your deployment.

    Customers Managing Their Own K8s Deployment

    If you are not using the PlainID Helm deployment and instead opt to build your own Kubernetes deployment procedures, you are required to configure the Redis user and password keys in the PAA services under the relevant Redis configuration entries.
    Use the following key pattern to integrate with the SM service and obtain the credentials:
    {{store=<store name>,key=<AWS SM key>,jsonpath=<AWS SM value jpath>}}

    Example:

    • Redis Connection Username: {{store=AWS_SECRETS_MANAGER_STORE,key=redis-rotated-pw,jsonpath=$.username}}
    • Redis Connection Password: {{store=AWS_SECRETS_MANAGER_STORE,key=redis-rotated-pw,jsonpath=$.password}}

    AWS Secrets Manager Secret Rotation

    AWS SM supports rotating ElastiCache for Redis secrets via Lambda, a service provided by Amazon. PlainID password rotation support, assuming that the AWS SM password rotation is implemented in the manner recommended by Amazon. See this guide for more information.

    Defining RDS Secrets Using the AWS RDS IAM Auth Store

    After setting up the new store you can define secrets, referencing the store based on the following structure {{store=<storeID>,key=<secretName>,refreshInterval=3s}}

    • storeID
      • The ID defined in the secret management service configuration.
    • secretName
      • The secret key name you want to consume from the store.
      • For the AWSRDSIAM store the key will be in the form user@host:port/region based on the AWS user you defined at the prerequisite.
    • refreshInterval
      • The interval used to fetch updates from the store.
      • Can be defined with s/m/h/d (sec/min/hours/days).
      • Note the default refresh interval for this store type is 10m which should be sufficient to accommodate AWS RDS's 15-min expiration policy.

    Using Secrets for PIP Data Sources

    When defining an AWS RDS database as a data source in PIP Management, use the secret syntax described above instead of the database password, ensuring the PIP Operator at the PAA level will consume this secret from Secret Management Service and establish DB connection with RDS.

    Example of a secret from RDS IAM - {{store=AWS_RDS_IAM_AUTH_STORE,key=user@aaa-bbb-ccc.cluster-c6wssjqgvz0f.us-east-2.rds.amazonaws.com:5432/us-east-2}}

    Using Secret for PDP Audit DB

    If an AWS RDS database needs to be defined as the PDP Authorization Audit database, the database connection is configured in the PDP settings using a few configuration keys. The configuration of the Secret itself will use similar secret syntax, but as its defined within a yaml configuration the double curly secret syntax needs to be wrapped with a printf command to be valid.

    Here is a set of Runtime config keys defining a connection to an AWS RDS DB:

    Environment Variable NameValue
    RTCONF_AUDIT__IS_DATA_BASE_ENABLEtrue
    RTCONF_AUDIT__CONNECTION__URL"jdbc:postgresql://aaa-bbb-ccc.cluster-c6wssjqgvz0f.us-east-2.rds.amazonaws.com:5432/sample_db"
    RTCONF_AUDIT__CONNECTION__USERdb_user
    RTCONF_AUDIT__CONNECTION__PASSWORD|-
      {{store=AWS_RDS_IAM_AUTH_STORE,key=test_user@shared-partner-mgmt-dev.cluster-g6wgs3hs1zff.eu-east-2.rds.amazonaws.com:5432/eu-east-2}}
    RTCONF_AUDIT__IS_USE_BATCH_MODEfalse

    Refer to our Runtime Service Configuration, Authorization Audit Configuration, and Policy Information Point articles for more specific information on how to use Environment Variables for generating tokens and passwords.

    Using Secret Manager for PDP JWT Signing

    The PlainID PDP (Runtime service) supports obtaining the authorization response as a signed JWT. This functionality requires retrieving a private key via the Secret Management Service, which is used for JWT signing, along with additional setup described below.

    Scope Level Configuration

    In addition to configuring the Secret Management Service and Secret Store in the Policy Authorization Agent (PAA), additional settings relating to JWT need to be configured in the PlainID Policy Administration Point (PAP).

    JWT Sign In Settings

    JWT Sign In Setting.png

    This section includes the relevant configuration attributes for obtaining the private key used to sign the PlainID Policy Decision Point (PDP) JWT.

    AttributeDescriptionBehavior
    Secret StoreThe ID of the Secret Store to use (PAA can use multiple Secret Stores).If no Secret Store is defined, the default secret store (where default=true) will be used. If a value is specified, the specified Secret Store will be used.
    Path to KeyDefine the path to the key location in the vault (relevant only for Secret Stores of type vault, not applicable for File or Environment Secret Stores).If not specified, the details.defaultPath from the Secret Store configuration will be used.
    Key NameDefine the name of the key in the vault (relevant only for Secret Stores of type vault, not applicable for File or Environment Secret Stores).If not defined, the PlainID Scope ClientID is used as the Key Name.

    JWT Response Settings

    JWT Response Setting image.png

    JWT Response Attribute Settings

    AttributeDescription
    AudienceThe value to include in the aud claim.
    X509 CertificateThe public X.509 certificate that is published in the PDP JWKS URL. This allows the consumer of the PDP decisions to validate the PDP Signed JWT. The child of the X.509 Certificate in the JWKS is the ClientID of the PlainID ScopeSample JWKS URL.
    Token Lifetime - EXP (Seconds)The token lifetime expiration in seconds.

    Was this article helpful?