gcloudjuice

package
v1.17.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Description: This package provides a set of functions to interact with Google Cloud services such as Secret Manager, Pub/Sub, and Maps.

Description: This package provides a set of functions to interact with Google Cloud services such as Secret Manager, Pub/Sub, and Maps.

Description: This package provides a set of functions to interact with Google Cloud services such as Secret Manager, Pub/Sub, and Maps.

Description: This package provides a set of functions to interact with Google Cloud services such as Secret Manager, Pub/Sub, and Maps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthenticateOIDCToken

func AuthenticateOIDCToken(ctx context.Context, r *http.Request, authTokenKey, expectedAudience, expectedIssuer string) (*structcup.AuthResponse, error)

AuthenticateOIDCToken verifies a JWT token's authenticity based on the provided audience and issuer.

It assumes the token is passed with the Bearer prefix.

It requires an HTTP response writer (w), an HTTP request (r), an authorization token key (authTokenKey), an expected audience (expectedAudience), and an expected issuer (expectedIssuer).

It returns a success response if the token is valid or an error if the token is invalid or does not match the expected audience and issuer.

func AuthenticateOIDCTokenCustomPrefix

func AuthenticateOIDCTokenCustomPrefix(ctx context.Context, r *http.Request, authTokenKey, prefix, expectedAudience, expectedIssuer string) (*structcup.AuthResponse, error)

AuthenticateOIDCToken verifies a JWT token's authenticity based on the provided audience and issuer.

It allows to specify a custom prefix for the authorization token instead of the default 'Bearer'.

It requires an HTTP response writer (w), an HTTP request (r), an authorization token key (authTokenKey), an expected audience (expectedAudience), and an expected issuer (expectedIssuer).

It returns a success response if the token is valid or an error if the token is invalid or does not match the expected audience and issuer.

func CreateOIDCToken

func CreateOIDCToken(ctx context.Context, FS embed.FS, credentialsPath string, audience string) (*oauth2.Token, error)

CreateOIDCToken creates an OIDC token with the given audience.

It requires an embedded filesystem (FS), a path to the credentials file (credentialsPath), and an audience (audience).

It returns the OIDC token or an error if the operation fails.

func DecodePubSubMessage

func DecodePubSubMessage(r *http.Request, message *pubsub.Message) error

DecodePubSubMessage decodes a Google Cloud Pub/Sub message from the request body and maps it to the provided Pub/Sub Message struct.

func GetSecretValue

func GetSecretValue(ctx context.Context, FS embed.FS, credentialsPath string, projectID string, secretID string, versionID string) ([]byte, error)

GetSecretValue retrieves a secret value from Google Cloud Secret Manager.

It requires an embedded filesystem (FS), a path to the credentials file (credentialsPath), a Google Cloud project ID (projectID), a secret ID (secretID), and a secret version ID (versionID).

It returns the secret value as a byte slice or an error if the operation fails.

func GetTimezoneFromCoordinates

func GetTimezoneFromCoordinates(ctx context.Context, c *maps.Client, latitude float64, longitude float64) (string, error)

GetTimezoneFromCoordinates retrieves the timezone from the given coordinates.

func NewMapsClient

func NewMapsClient(ctx context.Context, mapsApiKey string, qps int) (*maps.Client, error)

NewMapsClient creates a new Google Maps client.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL