1. Secure AI Model Serving Credentials with Vault Okta Groups

    Python

    HashiCorp Vault is a tool for secrets management, encryption as a service, and privileged access management. It allows you to securely store, access, and manage sensitive information such as tokens, passwords, certificates, encryption keys.

    In a scenario where you are serving an AI model and want to secure credentials using Vault with Okta for user authentication and authorization, we can use Pulumi to create the necessary resources. This includes setting up an Okta authentication backend in Vault, which allows users to authenticate with Vault using their Okta credentials, and organizing these users into groups to manage their permissions efficiently.

    In this example, we will create an Okta auth method in Vault and set up a group with specified policies.

    First, we create a new Okta authentication method in Vault, which requires the API token from Okta with the necessary permissions to interact with the Okta API. Then, we define a group in this auth method. This group holds policies that specify what members of this group are allowed to do within Vault.

    Here is a Python program using Pulumi, which sets up these resources:

    import pulumi import pulumi_vault as vault # Authentication method for Okta. # This requires an existing Okta account and organization. okta_auth_backend = vault.okta.AuthMethod("oktaAuthMethod", # The path for the Okta auth method in Vault (by default vault okta auth method's name itself). path="okta", description="Okta auth method for accessing Vault", # You must obtain this token from your Okta administrative interface for API integration. # It should have permissions to manage users and groups within Okta. token="<YOUR_OKTA_API_TOKEN>", ) # An Okta group that corresponds to a set of Vault policies. okta_auth_backend_group = vault.okta.AuthBackendGroup("oktaAuthBackendGroup", # The same path used for the AuthMethod. auth_backend_path=okta_auth_backend.path.apply(lambda path: path or "okta"), group_name="my-ai-model-users", # The name of the Okta group policies=["ai-model-user-policy"], # List of policies assigned to the group ) # Export the path of the auth method for reference. pulumi.export("oktaAuthPath", okta_auth_backend.path) # Use pulumi.Config to secure this sensitive information in the actual implementation. # config = pulumi.Config() # okta_token = config.require_secret("oktaApiToken")

    In this Pulumi code:

    • We created an Okta authentication method (AuthMethod) for Vault to use Okta as a user authentication mechanism for Vault.
    • We set up an Okta group (AuthBackendGroup) and associated it with policies that grant permissions within Vault.

    Please replace <YOUR_OKTA_API_TOKEN> with your actual Okta API token.

    The okta_auth_backend variable represents a Vault authentication method based on Okta, allowing users in your Okta organization to authenticate against Vault using their Okta credentials.

    The okta_auth_backend_group variable represents a Vault group that is configured to use the Okta authentication method. The policies list should contain the names of Vault policies that grant or deny access to Vault resources. This example assumes you have a Vault policy called ai-model-user-policy, which you would need to create separately according to your specific requirements.

    The pulumi.export line makes the path for the Okta authentication method available as an output, which can be useful if you want to reference it elsewhere.

    Make sure to handle your Okta API tokens securely:

    • Avoid hardcoding secrets in your code.
    • Use environment variables or Pulumi's configuration system to pass sensitive information securely.

    Remember that this is just a foundational setup. Depending on your needs, you may have to create additional Vault policies, configure more detailed access rules, manage more groups or users, and integrate this authentication setup into your AI model serving infrastructure.