Skip to main content

Module signer

Module signer 

Source
Expand description

Abstraction for signing arbitrary bytes using Google Cloud Credentials.

A Signer is used to sign data, typically for authentication or authorization purposes. One primary use case in the Google Cloud ecosystem is generating Signed URLs for Google Cloud Storage.

The main type in this module is Signer. This is an opaque type that implements the SigningProvider trait and can be used to sign content. Use crate::credentials::Builder::build_signer to create a Signer from loaded credentials.

§Example: Creating a Signer using Application Default Credentials (ADC)

This is the recommended way for most applications. It automatically finds credentials from the environment. See how Application Default Credentials works.

use google_cloud_auth::credentials::Builder;
use google_cloud_auth::signer::Signer;

let signer: Signer = Builder::default().build_signer()?;

§Example: Creating a Signer using a Service Account Key File

This is useful when you have a specific service account key file (JSON) and want to use it directly. Service account based signers work by local signing and do not make network requests, which can be useful in environments where network access is restricted and performance is critical.

Caution: Service account keys are a security risk if not managed correctly. See Best practices for managing service account keys for more information.
use google_cloud_auth::credentials::service_account::Builder;
use google_cloud_auth::signer::Signer;

let service_account_key = serde_json::json!({ /* add details here */ });

let signer: Signer = Builder::new(service_account_key).build_signer()?;

Structs§

Signer
An implementation of crate::signer::SigningProvider that wraps a dynamic provider.
SigningError
Represents an error occurred during a signing operation.

Traits§

SigningProvider
A trait for types that can sign content.

Type Aliases§

Result