aws_cloudfront_token

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: MIT Imports: 10 Imported by: 0

README

aws_cloudfront_token

golang: aws cloudfront token signer

status: production ready GoDoc

import (
	"io/ioutil"
	"log"
	"time"

	"github.com/getto-systems/aws_cloudfront_token-go"
)

pem, err := ioutil.ReadFile("path/to/aws_cloudfront_key_pair/pk.pem")
if err != nil {
	log.Fatal(err)
}

privateKey := aws_cloudfront_token.KeyPairPrivateKey(pem)

resource := "https://AWS_CLOUDFRONT_BASE_URL/*"
expires: := time.Now().Add(time.Duration(30 * 1_000_000_000)), // expires 30 seconds after

token, err := privateKey.Sign(resource, expires)
if err != nil {
	log.Fatal(err)
}

// token.Policy    // aws cloudfront fravor base64 encoded string
// token.Signature // aws cloudfront fravor base64 encoded string
Table of Contents

Requirements

  • golang: 1.14

License

MIT license.

Copyright © shun-fix9

Documentation

Overview

Package aws_cloudfront_token provides AWS-CloudFront-Signed-Cookie signer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyPairPrivateKey added in v1.0.0

type KeyPairPrivateKey []byte

func (KeyPairPrivateKey) Sign added in v1.0.0

func (privateKey KeyPairPrivateKey) Sign(resource string, expires time.Time) (SignedCookieToken, error)

type SignedCookieToken added in v1.0.0

type SignedCookieToken struct {
	// CloudFront flavored base64 string
	Policy string
	// CloudFront flavored base64 string
	Signature string
}

AWS CloudFront Signed Cookie Token

Jump to

Keyboard shortcuts

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