auth

package module
v0.0.0-...-7a7d42c Latest Latest
Warning

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

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

README

martini-keystone-auth

About:

Validates keystone auth tokens and injects them into the martini context.

Installation:

go get github.com/Kuwagata/martini-keystone-auth

Example usage:
package main

import (
	"github.com/go-martini/martini"
	"github.com/Kuwagata/martini-keystone-auth"
)

func main() {
	identity_tokens_endpoint := "https://identity.api.rackspacecloud.com/v2.0/tokens"

	redis_hostname := "localhost"
	redis_port := "6379"
	redis_pw := ""
	redis_db := int64(0)

	m := martini.Classic()
	m.Use(auth.Keystone(
		auth.GetIdentityValidator(identity_tokens_endpoint),
		auth.GetRedisCache(redis_hostname, redis_port, redis_pw, redis_db)))
	m.Get("/", func(token auth.Token) string {
		return string(token)
	})
	m.Run()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Keystone

func Keystone(validator TokenValidator, cache Cache) martini.Handler

Types

type Cache

type Cache interface {
	Get(key string) (string, error)
	Set(key, value string) error
}

func GetRedisCache

func GetRedisCache(hostname, port, password string, database int64) Cache

type IdentityValidator

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

func (IdentityValidator) ValidateToken

func (i IdentityValidator) ValidateToken(token string) bool

type Redis

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

func (Redis) Get

func (r Redis) Get(key string) (string, error)

func (Redis) Set

func (r Redis) Set(key, value string) error

type Token

type Token string

type TokenValidator

type TokenValidator interface {
	ValidateToken(token string) bool
}

func GetIdentityValidator

func GetIdentityValidator(auth_url string) TokenValidator

Jump to

Keyboard shortcuts

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