Documentation
¶
Index ¶
- Constants
- type Option
- type SignParams
- type URLSigner
- func (u *URLSigner) DeletePath(bucket, path string) (string, error)
- func (u *URLSigner) DownloadPath(bucket, path string) (string, error)
- func (u *URLSigner) Make(p *SignParams, d time.Duration) (string, error)
- func (u *URLSigner) MakeURL(method, bucket, path string, d time.Duration, headers map[string]string) (string, error)
- func (u *URLSigner) Sign(method, hash, contentType, bucket, path string, headers map[string]string) (string, error)
- func (u *URLSigner) SignParams(p *SignParams) (string, error)
- func (u *URLSigner) UploadPath(bucket, path string) (string, error)
Constants ¶
const ( // DefaultBaseURL is the base Google Storage URL. DefaultBaseURL = "https://storage.googleapis.com" // DefaultExpiration is the default expiration for signed URLs. DefaultExpiration = 1 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
Option represents a URLSigner option.
func GoogleServiceAccountCredentialsFile ¶
GoogleServiceAccountCredentialsFile is an option that loads Google Service Account credentials for from the specified file.
Google Service Account credentials can be downloaded from the Google Cloud console: https://console.cloud.google.com/iam-admin/serviceaccounts/
func GoogleServiceAccountCredentialsJSON ¶
GoogleServiceAccountCredentialsJSON is an option that loads Google Service Account credentials from a JSON encoded buf.
Google Service Account credentials can be downloaded from the Google Cloud console: https://console.cloud.google.com/iam-admin/serviceaccounts/
type SignParams ¶
type SignParams struct {
// BaseURL is the URL to use for building the URL. If not supplied, then
// DefaultBaseURL will be used instead.
BaseURL string
// Method is the HTTP method (GET, PUT, ...).
Method string
// Hash is the md5 hash of the file content for an upload.
Hash string
// ContentType is the content type of the uploaded file.
ContentType string
// Expiration is the expiration time of a generated signature.
Expiration time.Time
// Headers are the extra headers.
Headers map[string]string
// Bucket is the storage bucket.
Bucket string
// Object is the object path.
Object string
}
SignParams are the signing params for generating a signed URL.
func (SignParams) HeaderString ¶
func (p SignParams) HeaderString() string
HeaderString sorts the headers in order, returning an ordered, usable string for use with signing.
func (SignParams) ObjectPath ¶
func (p SignParams) ObjectPath() string
ObjectPath returns the canonical path.
func (SignParams) String ¶
func (p SignParams) String() string
String satisfies stringer returning the formatted string suitable for use with the URLSigner.
type URLSigner ¶
type URLSigner struct {
PrivateKey *rsa.PrivateKey
ClientEmail string
}
URLSigner provides a type that can generate signed URLs for use with Google Cloud Storage.
func NewURLSigner ¶
NewURLSigner creates a new URLSigner
func (*URLSigner) DeletePath ¶
DeletePath generates a signed path for deleting an object.
func (*URLSigner) DownloadPath ¶
DownloadPath generates a signed path for downloading an object.
func (*URLSigner) MakeURL ¶
func (u *URLSigner) MakeURL(method, bucket, path string, d time.Duration, headers map[string]string) (string, error)
MakeURL creates a signed URL for the method.
func (*URLSigner) Sign ¶
func (u *URLSigner) Sign(method, hash, contentType, bucket, path string, headers map[string]string) (string, error)
Sign creates the signature for the provided method, hash, contentType, bucket, and path accordingly.
func (*URLSigner) SignParams ¶
func (u *URLSigner) SignParams(p *SignParams) (string, error)
SignParams signs using the URLSigner.