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
- func AuthenticateOIDCToken(ctx context.Context, r *http.Request, ...) (*structcup.AuthResponse, error)
- func AuthenticateOIDCTokenCustomPrefix(ctx context.Context, r *http.Request, ...) (*structcup.AuthResponse, error)
- func CreateOIDCToken(ctx context.Context, FS embed.FS, credentialsPath string, audience string) (*oauth2.Token, error)
- func DecodePubSubMessage(r *http.Request, message *pubsub.Message) error
- func GetSecretValue(ctx context.Context, FS embed.FS, credentialsPath string, secret SecretInfo) ([]byte, error)
- func GetTimezoneFromCoordinates(ctx context.Context, c *maps.Client, latitude float64, longitude float64) (string, error)
- func NewMapsClient(ctx context.Context, mapsApiKey string, qps int) (*maps.Client, error)
- type PubSubMessageKey
- type SecretInfo
- type Subscription
- type Topic
- type Value
Constants ¶
const ( // SMS. // This section contains keys to perform the sending of SMS messages. // Webhook is located in sms microservice. SMSTopicKey Topic = "sms1" SMSSubKey Subscription = "sms1" SMSRecipientKey PubSubMessageKey = "recipient" SMSCodeKey PubSubMessageKey = "code" // Reports. // This section contains keys to perform the generation of PDF reports. // Webhook is located in reports microservice. ReportsPDFTopicKey Topic = "pdf1" ReportsPDFSubKey Subscription = "pdf1" ReportsPDFDocIDKey PubSubMessageKey = "_id" ReportsPDFTypeKey PubSubMessageKey = "pdf_type" ReportsPDFCurrencyKey PubSubMessageKey = "currency" ReportsPDFIsTestKey PubSubMessageKey = "is_test" ReportsPDFTypeBill Value = "bills" ReportsPDFTypePayroll Value = "payrolls" ReportsPDFTypeDeductionAggregation Value = "deductionaggregations" // Emails. // This section contains keys to send emails. // More keys are defined directly in gojuice/emailjuice package. // Webhook is located in email microservice. EmailsTopicKey Topic = "email" EmailsSubKey Subscription = "email" )
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 ¶
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, secret SecretInfo) ([]byte, error)
GetSecretValue retrieves a secret value from Google Cloud Secret Manager.
It returns the secret value as a byte slice or an error if the operation fails.
Types ¶
type PubSubMessageKey ¶ added in v1.27.0
type PubSubMessageKey = string
type SecretInfo ¶ added in v1.35.18
type Subscription ¶ added in v1.27.1
type Subscription = string