Use this flow when the API grants access to a signed-in user. Register a public OAuth client with
the API's authorization server, enable authorization code with S256 PKCE, and register the
exact callback http://127.0.0.1:8765/callback. Ask for the scopes the API requires, including
any scope the authorization server requires to issue a refresh token.
-
Set the authorization and token endpoints and client ID in your environment.
export STACKQL_OAUTH_AUTHORIZE_URL='https://issuer.example/authorize' export STACKQL_OAUTH_TOKEN_URL='https://issuer.example/token' export STACKQL_OAUTH_CLIENT_ID='your-client-id'
-
Start StackQL in the terminal where you'll sign in. Replace
myproviderwith the name of the installed provider and replacereadwith the API's scope.stackql shell --preview='{"unstable":true}' --auth='{ "myprovider": { "type": "interactive", "authorization_url_env_var": "STACKQL_OAUTH_AUTHORIZE_URL", "token_url_env_var": "STACKQL_OAUTH_TOKEN_URL", "client_id_env_var": "STACKQL_OAUTH_CLIENT_ID", "redirect_uri": "http://127.0.0.1:8765/callback", "scopes": ["read"] } }'
-
Run
AUTH LOGIN myprovider INTERACTIVE;. Open the URL StackQL prints in a browser on the same machine, sign in, and return to the terminal after the callback. -
Run your provider query in that StackQL session. StackQL refreshes the access token before a query when needed.
To sign in again, run AUTH REVOKE myprovider; followed by
AUTH LOGIN myprovider INTERACTIVE;. The authorization server may reuse your browser session.
StackQL uses the same access token throughout a query. If it expires mid-query, sign in again
if refresh fails, then rerun the query. StackQL has no command to force a refresh while the
cached access token is valid.
For a confidential client, set client_secret_env_var to the name of the environment variable
that holds its secret. To use a different callback port or path, update both redirect_uri and
the registered callback. The callback must use HTTP on a loopback IP.
For a local end-to-end check, the Keycloak Robot suite starts Keycloak in Docker, signs in, and queries its UserInfo endpoint through StackQL.
Using a terminal, enter az login and then follow the login flow in the browser.
Having done this, pass the --auth parameter into stackql with Azure configured to use default auth, like this: --auth='{ "azure": { "type": "azure_default" }, ... }'. Then, Azure auth should proceed transparently.
Add the AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET environment variables, as per the documentation for the golang SDK.
Having done this, pass the --auth parameter into stackql with Azure configured to use default auth, like this: --auth='{ "azure": { "type": "azure_default" }, ... }'. Then, Azure auth should proceed transparently.
- Terraform: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
- SDK: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity#section-readme
- Azure Service Principal setup: https://learn.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication-service-principal?tabs=azure-cli
Type oci_signing_v1 signs requests with the OCI draft-cavage HTTP signature scheme (Authorization: Signature version="1",keyId="<tenancy_ocid>/<user_ocid>/<fingerprint>",algorithm="rsa-sha256",...). GET/DELETE sign date (request-target) host; POST/PUT/PATCH additionally sign content-length, content-type and x-content-sha256.
Credentials are supplied via the --auth context. Two variants:
Supply all of tenancy OCID, user OCID, fingerprint and a private key. Every field accepts a literal key (tenancy_ocid, user_ocid, fingerprint, private_key, private_key_path, passphrase, region) or an env var indirection (tenancy_ocid_env_var, user_ocid_env_var, fingerprint_env_var, private_key_env_var, private_key_path_env_var, passphrase_env_var, region_env_var); when the *_env_var key is set it wins over the literal. passphrase and region are optional.
{"oci": {"type": "oci_signing_v1", "tenancy_ocid_env_var": "OCI_CLI_TENANCY", "user_ocid_env_var": "OCI_CLI_USER", "fingerprint_env_var": "OCI_CLI_FINGERPRINT", "private_key_path_env_var": "OCI_CLI_KEY_FILE"}}The env var names are free-form; the example uses the exact names the OCI CLI reads (OCI_CLI_TENANCY, OCI_CLI_USER, OCI_CLI_FINGERPRINT, OCI_CLI_KEY_FILE, OCI_CLI_PASSPHRASE, OCI_CLI_REGION) so an environment configured for the CLI works unchanged. Terraform users can point the *_env_var keys at their TF_VAR_* names instead, or skip env vars entirely with the config file variant below - it reads the same ~/.oci/config as both tools.
If any of the four raw values is present, all four are required; a partial set fails fast with cannot compose OCI signing credentials: ... and no request is sent.
When no raw value is present, the standard OCI config file convention applies:
{"oci": {"type": "oci_signing_v1", "config_file_path": "/home/user/.oci/config", "profile": "DEFAULT"}}config_file_path defaults to ~/.oci/config and profile to DEFAULT; passphrase / passphrase_env_var also apply to the config file key. This is the same file used by the OCI CLI and Terraform.
k8s supports an adaptable auth flow client-go credential plugins, which can be and is leveraged by k8s vendors.
- Google have chosen to funnel their k8s auth offering through a
gcloudplugin, which is opaque. Here is a community golang implementation. 4
We implemented standard AWS cross-account access using sts:AssumeRole. The client account/user/runner is granted permission to assume a read-only audit role in the target account, while the target role trusts the client principal via a trust policy, optionally guarded by ExternalId. The target role was granted SecurityAudit, S3 read permissions, and Cloud Control (cloudformation:ListResources, cloudformation:GetResource, etc.) permissions so StackQL can perform live control-plane audits using temporary STS credentials rather than long-lived target-account keys. Docs: https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html
The --auth JSON string can be configured to assume a foreign role. This relies on assume-role access being configured in the target tenancy/account.
{"aws":{"type":"aws_assume_role","keyIDenvvar":"AWS_ACCESS_KEY_ID","credentialsenvvar":"AWS_SECRET_ACCESS_KEY","aws_role_arn":"arn:aws:iam::123456789012:role/MyRole"}}We implemented Azure cross-tenant access using a multitenant App Registration in the client tenant. The target tenant admin granted consent to the application, which created an Enterprise Application/service principal inside the target tenant. The target tenant then assigned the built-in Reader role to that enterprise application at the subscription or management-group scope. StackQL authenticates using the client application's client_id and client_secret, but requests tokens from the target tenant authority to audit target Azure resources. Docs: https://learn.microsoft.com/en-us/entra/identity-platform/howto-convert-app-to-be-multi-tenant
No change to canonical Azure configuration is needed; use the client app ID/secret, the target tenant ID, and the target subscription ID.
We implemented GCP cross-organization access by creating a service account in the client project and granting that foreign service account IAM roles directly in the target organization/project. The target org/project granted roles such as Viewer, Security Reviewer, and Folder Viewer to the client-owned service account principal, allowing StackQL to audit the target environment while authenticating only with the client-side service account key. Docs: https://cloud.google.com/iam/docs/granting-changing-revoking-access
There is no change to existing Google auth for this.
Example, presuming the sourced script contains the cited env vars:
source cicd/vol/vendor-secrets/foreign_to_stackql_user.sh
stackql --auth '{"aws":{"type":"aws_assume_role","keyIDenvvar":"AWS_ACCESS_KEY_ID","credentialsenvvar":"AWS_SECRET_ACCESS_KEY","aws_role_arn":"'"${STACKQL_AUDIT_ROLE_ARN}"'"}}' shellUse a StackQL build with native Identity Center support and an AWS permission set that
allows ec2:DescribeVpcs in the account you want to query. StackQL handles the device
flow and signs requests with the temporary role credentials. The AWS CLI is optional.
-
Configure a named profile in
~/.aws/configor the file selected byAWS_CONFIG_FILE. Replace the example account, permission set role, portal URL, and Identity Center region with the values provided by your AWS administrator.[profile engineering] sso_session = company sso_account_id = 123456789012 sso_role_name = ReadOnlyAccess [sso-session company] sso_start_url = https://example.awsapps.com/start sso_region = us-east-1 sso_registration_scopes = sso:account:access
-
Start StackQL with the profile selection. Clearing shell credentials for this command lets the shared-config profile supply the credentials. Use a profile name with no static keys in the shared credentials file and no
credential_process.env -u AWS_ACCESS_KEY_ID -u AWS_SECRET_ACCESS_KEY -u AWS_SESSION_TOKEN \ stackql shell --preview='{"unstable":true}' \ --auth='{"aws":{"type":"aws_identity_center","aws_profile":"engineering"}}'
-
If the AWS provider is missing, install it from the StackQL registry. Start the login in the same shell.
REGISTRY PULL aws v26.08.00444; AUTH LOGIN aws INTERACTIVE;
Open the verification URL printed by StackQL, enter the displayed code, and approve the request in the browser. Add
"open_browser": trueto the AWS auth object to launch the default browser automatically. StackQL still prints the URL and code. Return to StackQL after the browser confirms sign-in. -
List VPCs with a read-only query. Set the query region to the region containing your VPCs. The query region is independent of
sso_region.SELECT VpcId FROM stackql_unstable_aws.ec2.vpcs WHERE region = 'ap-southeast-2';
StackQL saves the login in the private
aws-ssodirectory under--approot. With the same app root and AWS configuration, a new shell can reuse or refresh the login automatically. Keep the app root on a private local filesystem. If a second profile references the samesso_session, select it withSET "$.auth.aws.aws_profile" = 'another-profile';and rerun the query. A profile referencing a different SSO session needs its ownAUTH LOGIN. -
Run
AUTH REVOKE aws;to delete the saved StackQL login. Trying the query again returns a sign-in-required error. The next login may reuse your browser's AWS session.
The Identity Center Robot suite runs without the AWS CLI and verifies the login prompts, account and role selection, credential reuse and refresh, and SigV4 requests.
This configuration requires a StackQL build that includes Omni's workload federation support. Configure the cloud to trust your issuer and restrict it to the workload's subject and audience.
For Bitbucket Pipelines → AWS, enable oidc: true on the pipeline step. Register the
workspace issuer and audience in AWS IAM and allow the step's subject to assume the role.
In that step, set STACKQL_AWS_ROLE_ARN to the role ARN and run:
stackql exec 'SELECT name FROM aws.s3.buckets;' --preview='{"unstable":true}' --auth='{
"aws": {
"federation": {
"source": "bitbucket",
"target": "aws",
"role_arn_env_var": "STACKQL_AWS_ROLE_ARN",
"region": "us-east-1"
}
}
}'StackQL passes the provider's federation config to Omni. Omni reads
BITBUCKET_STEP_OIDC_TOKEN, exchanges it for temporary AWS credentials, and signs the API
request. For GitHub use source: github with audience and id-token: write. For GitLab
use source: gitlab with token_env_var. For Kubernetes use source: kubernetes with
token_file. An issuer such as Keycloak can also supply an assertion via source: keycloak
with its token URL and client credential environment selectors.
Bitbucket Pipelines OIDC setup
Give the job permissions: {id-token: write}. Configure the cloud to trust
https://token.actions.githubusercontent.com and restrict the subject to your repository and
branch or deployment environment. To run the AWS example above from the job, replace its
federation block with this one. StackQL requests the assertion from the runner.
{
"source": "github",
"audience": "sts.amazonaws.com",
"target": "aws",
"role_arn_env_var": "STACKQL_AWS_ROLE_ARN",
"region": "us-east-1"
}Run StackQL in a Pod with a dedicated service account. Add a projected serviceAccountToken
to a volume mounted at /var/run/federation. This example uses an AWS trust policy that accepts
the cluster issuer, audience sts.amazonaws.com, and subject
system:serviceaccount:<namespace>:<service-account>.
volumes:
- name: federation
projected:
sources:
- serviceAccountToken:
audience: sts.amazonaws.com
expirationSeconds: 3600
path: tokenMount the volume in the StackQL container. In the AWS example above, set
"source": "kubernetes" and add "token_file": "/var/run/federation/token".
Omni reads the current file when it needs to exchange an assertion. Kubernetes token projection
In your realm, create an OpenID Connect client with Client authentication and
Service accounts roles enabled. Configure an audience mapper so the client access token
carries the audience your cloud trusts. Set KEYCLOAK_CLIENT_ID and KEYCLOAK_CLIENT_SECRET
in the StackQL process environment. For Google Cloud, create an OIDC workload identity pool
provider for the realm and bind the mapped principal to the resource it can read.
Pass this object to --auth and run a query such as
SELECT name FROM google.storage.buckets WHERE project = 'my-project';. Substitute your realm
endpoint, workload identity pool provider resource, and project.
{
"google": {
"federation": {
"source": "keycloak",
"target": "gcp",
"issuer_token_url": "https://keycloak.example/realms/demo/protocol/openid-connect/token",
"issuer_client_id_env_var": "KEYCLOAK_CLIENT_ID",
"issuer_client_secret_env_var": "KEYCLOAK_CLIENT_SECRET",
"google_audience": "//iam.googleapis.com/projects/123456789/locations/global/workloadIdentityPools/demo/providers/keycloak"
}
}
}Set google_service_account if the workload should impersonate a service account. Google Cloud federation setup
GHA → cloud federation via each provider's official action; stackql then uses its standard auth types — no federation-specific --auth string needed.
Workflow needs permissions: id-token: write, then per cloud:
AWS — GitHub docs. IAM OIDC provider + role; aws-actions/configure-aws-credentials@v4 with role-to-assume. Session token (AWS_SESSION_TOKEN) is picked up from env automatically — no extra field needed.
--auth '{"aws":{"type":"aws_signing_v4","keyIDenvvar":"AWS_ACCESS_KEY_ID","credentialsenvvar":"AWS_SECRET_ACCESS_KEY"}}'
GCP — GitHub docs. Workload Identity Pool + Provider, SA bound via both roles/iam.workloadIdentityUser and roles/iam.serviceAccountTokenCreator (the access-token mint path needs Token Creator on top of WIU); google-github-actions/auth@v2 with workload_identity_provider + service_account + token_format: 'access_token'. Capture the action's access_token output into an env var (e.g. GCP_ACCESS_TOKEN) for the stackql step. The action's default external_account credentials file isn't consumable by stackql's service_account type.
--auth '{"google":{"type":"bearer","credentialsenvvar":"GCP_ACCESS_TOKEN"}}'
Azure — action docs. Entra app + federated credential (one per org — Azure won't accept repository_owner matching); azure/login@v2 with client/tenant/subscription IDs.
--auth '{"azure":{"type":"azure_default"}}'
- GCP: use Workload Identity Federation (project-scoped), not Workforce. Impersonation via
token_format: access_tokenneeds bothroles/iam.workloadIdentityUserandroles/iam.serviceAccountTokenCreatoron the SA. GH secret = full provider resource name (projects/.../providers/...). - Azure: federated credentials for GHA disallow
repository_ownermatching → create one credential per org, or regex onclaims['sub'].