Module gcp_service_account_auth

kotsikau/gcp_service_account_auth

0.1.0
GCP Service Account Auth Policy

Overview

Request-flow custom mediation policy for WSO2 API Platform / Bijira.

This policy authenticates outbound calls to a downstream Google-protected endpoint by:

  • accepting a Google service-account JSON key as a policy parameter
  • minting a JWT assertion with the service-account private key
  • exchanging the assertion at Google's OAuth2 token endpoint
  • caching the resulting access token in memory per mediation application instance
  • injecting Authorization: Bearer <access-token> into the outbound request

Parameters

ParameterTypeDescription
serviceAccountJsonstringMinified Google service-account JSON key content.
scopestringOAuth scope to request from Google.
authHeaderNamestringHeader to populate. Defaults to Authorization when blank.
refreshSkewSecondsintRefresh window before token expiry. Defaults to 300 when <= 0.

Deployment notes

  • Publish this package to Ballerina Central, then attach it from the API Platform Console.
  • Set the org field in Ballerina.toml to your actual Ballerina Central organization before bal push.
  • In the console, prefer deploy-time variables such as ${GCP_SERVICE_ACCOUNT_JSON} and ${GCP_SCOPE} instead of hardcoding secrets.
  • Each mediation application instance caches tokens independently. There is no cross-node cache.
  • The policy uses token_uri from the service-account JSON when present, and otherwise falls back to Google's default token endpoint.

Import

import kotsikau/gcp_service_account_auth;Copy

Other versions

Metadata

Released date: 5 days ago

Version: 0.1.0


Compatibility

Platform: any

Ballerina version: 2201.13.3

GraalVM compatible: Yes


Pull count

Total: 2

Current verison: 0


Weekly downloads



Keywords

choreo-apim-mediation-policy

choreo-apim-mediation-request-flow