atm

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2015 License: BSD-3-Clause Imports: 23 Imported by: 0

README

ATM - Automated Tempurl Maker

Quick/basic REST endpoint to generate Swift TempURLs

Why

The basic idea is to use this for other devives to upload without having to distribute the Swift credentials to those devices. The idea came from http://torgomatic.us/blog/2013/05/09/tempurl-tricks-write-only-access-for-backups

Usage

Installaion

Configuration

License

BSD 3-Clause

Documentation

Overview

http://openmymind.net/Shard-Your-Hash-table-to-reduce-write-locks/

Copyright (c) 2015 Stuart Glenn All rights reserved Use of this source code is goverened by a BSD 3-clause license, see included LICENSE file for details Datastore for perstiance of access rules, clients & keys

ATM - Automatic TempUrl Maker Copyright (c) 2015 Stuart Glenn All rights reserved Use of this source code is goverened by a BSD 3-clause license, see included LICENSE file for details Contains the main logic behind making TempUrls

Index

Constants

View Source
const (
	HOST     = "https://o3.omrf.org"
	DURATION = 5 * time.Minute
)
View Source
const API_KEY = "api-key"
View Source
const AUTH_SEP = ":"
View Source
const CONTENT_MD5 = "Content-MD5"
View Source
const CONTENT_TYPE = "Content-Type"
View Source
const XNONCE = "X-Nonce"
View Source
const XTIME = "X-Timestamp"

Variables

This section is empty.

Functions

func ErrMsg

func ErrMsg(msg string) map[string]string

func HMACAuth

func HMACAuth(o *HmacOpts) echo.HandlerFunc

Types

type Account

type Account struct {
	Id   string `json:id`
	Name string `json:name`
}

type AtmClient

type AtmClient struct {
	ApiKey    string
	ApiSecret string
	AtmHost   string
}

func (*AtmClient) RequestTempUrl

func (c *AtmClient) RequestTempUrl(method, account, container, object string) (string, error)

type Authorizor

type Authorizor struct {
	ApiKey    string
	Signature string
	Md5       string
	Type      string
	Nonce     string
	Xtime     string
	Method    string
	Uri       string
	Timestamp time.Time
	Opts      *HmacOpts
}

func AuthorizorForRequest

func AuthorizorForRequest(o *HmacOpts, method string, uri string) *Authorizor

func (*Authorizor) Authentic

func (a *Authorizor) Authentic(r *http.Request) error

func (*Authorizor) SignatureWith

func (a *Authorizor) SignatureWith(key string) string

func (*Authorizor) SigningString

func (a *Authorizor) SigningString() string

Build the content for signging & sign it with the key method\nURI\nMD5\ntype\ntimestamp\nnonce

type Cache

type Cache map[string]*shard

func NewCache

func NewCache() *Cache

func (*Cache) Delete

func (c *Cache) Delete(key string)

func (*Cache) Get

func (c *Cache) Get(key string) (interface{}, bool)

func (*Cache) Set

func (c *Cache) Set(key string, data interface{})

type Datastore

type Datastore struct {
	// contains filtered or unexported fields
}

func NewDatastore

func NewDatastore(driver, dsn string) (*Datastore, error)

func (*Datastore) Account

func (d *Datastore) Account(name string) (*Account, error)

func (*Datastore) AddSigningKeyForAccount

func (d *Datastore) AddSigningKeyForAccount(key, account string)

func (*Datastore) ApiKeySecret

func (d *Datastore) ApiKeySecret(apiKey string) (string, error)

func (*Datastore) Close

func (d *Datastore) Close() error

func (*Datastore) KeyForRequest

func (d *Datastore) KeyForRequest(u *UrlRequest, appId string) (string, int64, error)

func (*Datastore) Ping

func (d *Datastore) Ping() error

func (*Datastore) RemoveSigningKeyForAccount

func (d *Datastore) RemoveSigningKeyForAccount(account string)

type ExpiringCache

type ExpiringCache struct {
	// contains filtered or unexported fields
}

func NewExpiringCache

func NewExpiringCache(scrubInterval time.Duration) *ExpiringCache

func (ExpiringCache) DeleteExpired

func (c ExpiringCache) DeleteExpired()

func (*ExpiringCache) Get

func (c *ExpiringCache) Get(k string) (interface{}, bool)

func (*ExpiringCache) Set

func (c *ExpiringCache) Set(k string, v interface{}, d time.Duration)

type HmacOpts

type HmacOpts struct {
	AuthPrefix   string
	Expiration   time.Duration
	SecretKeyFor KeyFinder
	NonceChecker NonceChecker
}

func NewHmacOpts

func NewHmacOpts(f KeyFinder, nc NonceChecker) *HmacOpts

type KeyFinder

type KeyFinder func(string) (string, error)

type NonceChecker

type NonceChecker interface {
	Add(string)
	Valid(string) bool
}

type NonceStore

type NonceStore struct {
	// contains filtered or unexported fields
}

func NewNonceStore

func NewNonceStore() NonceStore

func (NonceStore) Add

func (d NonceStore) Add(n string)

func (NonceStore) Valid

func (d NonceStore) Valid(n string) bool

type Server

type Server struct {
	Ds               *Datastore
	Object_host      string
	Default_duration int64
	Nonces           NonceChecker
}

func (*Server) Run

func (a *Server) Run()

type Tmpurl

type Tmpurl struct {
	Url  string `json:"url"`
	Path string `json:"path"`
}

type UrlRequest

type UrlRequest struct {
	Account   string `json:account`
	Container string `json:container`
	Object    string `json:object`
	Method    string `json:method`
	Key       string `json:"-"`
	Host      string `json:"-"`
	Duration  int64  `json:"-"`
}

func (*UrlRequest) Path

func (u *UrlRequest) Path() string

func (*UrlRequest) SignedUrl

func (u *UrlRequest) SignedUrl() string

func (*UrlRequest) Valid

func (u *UrlRequest) Valid() bool

Directories

Path Synopsis
ATM - Automatic TempUrl Maker A builder of Swift TempURLs Copyright (c) 2015 Stuart Glenn All rights reserved Use of this source code is goverened by a BSD 3-clause license, see included LICENSE file for details
ATM - Automatic TempUrl Maker A builder of Swift TempURLs Copyright (c) 2015 Stuart Glenn All rights reserved Use of this source code is goverened by a BSD 3-clause license, see included LICENSE file for details

Jump to

Keyboard shortcuts

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