token

package
v0.0.0-...-72324ba Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2015 License: Apache-2.0 Imports: 6 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Db

type Db interface {
	// 取得。
	Get(id string) (*Element, error)

	// 保存。
	// exp: 保存期限。この期間以降は Get や Replace できなくて良い。
	Save(elem *Element, exp time.Time) error

	// 上書き。
	// savedDate が保存されている要素の更新日時と同じでなければ失敗する。
	Replace(elem *Element, savedDate time.Time) (ok bool, err error)
}

アクセストークン情報の格納庫。

func NewMemoryDb

func NewMemoryDb() Db

func NewRedisDb

func NewRedisDb(pool *redis.Pool, tag string) Db

redis によるアクセストークン情報の格納庫。 本体と別に更新日時を、日時タグと ID をキーにして、Unix 時間 (ナノ秒) で格納。 RFC3339 じゃない理由は同値比較でタイムゾーンを考えたくないから。

type Element

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

アクセストークン情報。

func New

func New(id string, exp time.Time, acnt string, scop, attrs map[string]bool, ta string) *Element

func (*Element) Account

func (this *Element) Account() string

アカウント ID を返す。

func (*Element) AddToken

func (this *Element) AddToken(tok string)

発行したアクセストークンを保存する。

func (*Element) Attributes

func (this *Element) Attributes() map[string]bool

許可属性を返す。

func (*Element) Date

func (this *Element) Date() time.Time

更新日時を返す。

func (*Element) Expires

func (this *Element) Expires() time.Time

有効期限を返す。

func (*Element) Id

func (this *Element) Id() string

ID を返す。

func (*Element) Invalid

func (this *Element) Invalid() bool

無効にされているかどうか。

func (*Element) Invalidate

func (this *Element) Invalidate()

無効にする。

func (*Element) MarshalJSON

func (this *Element) MarshalJSON() (data []byte, err error)
{
    "id": <ID>,
    "invalid": <無効か>,
    "expires": <有効期限>,
    "account": <アカウント ID>,
    "scope": [
        <許可スコープ>,
        ...
    ],
    "attributes": [
        <許可属性>,
        ...
    ],
    "client_id": <TA の ID>,
    "tokens": [
        <アクセストークン>,
        ...
    ],
    "date": <更新日時>
}

func (*Element) Scope

func (this *Element) Scope() map[string]bool

許可スコープを返す。

func (*Element) Ta

func (this *Element) Ta() string

TA の ID を返す。

func (*Element) Tokens

func (this *Element) Tokens() map[string]bool

発行したアクセストークンを返す。

func (*Element) UnmarshalJSON

func (this *Element) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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