sso

package module
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2016 License: MIT Imports: 22 Imported by: 0

README

sso

This project is a port of travis-sso from ruby to go.

When we deploy stuff to heroku, we want to make sure it is not accessible to the whole world. With ruby apps we can use travis-sso as a rack middleware. This is not as easy for non-ruby stuff though.

This project aims to make that easier by implementing an HTTP reverse proxy server that sits in front of the application and requires users to authenticate.

Session information is stored in an encrypted cookie (authenticated encryption), and a Travis-State header is provided to the application with JSON-encoded information about the authenticated user.

Installation

$ go get -u github.com/FiloSottile/gvt
$ gvt restore

Run

$ go run cmd/sso/main.go -upstream 'https://gif.industries' -app 'http://localhost:8080' -encryption-key $(pwgen 32 1) -csrf-key $(pwgen 32 1) -authorized-users 'igorwwwwwwwwwwwwwwwwwwww,svenfuchs'

Release

$ git tag v0.1.10
$ git push origin v0.1.10
$ make github-release

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset added in v0.1.3

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir added in v0.1.3

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo added in v0.1.3

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames added in v0.1.3

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset added in v0.1.3

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset added in v0.1.3

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets added in v0.1.3

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type APIMessage

type APIMessage struct {
	User User `json:"user"`
}

type SSO

type SSO struct {
	UpstreamURL   *url.URL
	APIURL        *url.URL
	AppPublicURL  *url.URL
	EncryptionKey []byte
	CSRFAuthKey   []byte
	Authorized    func(User) (bool, error)
}

func (*SSO) ServeHTTP

func (sso *SSO) ServeHTTP(w http.ResponseWriter, req *http.Request)

type State

type State struct {
	User  User   `json:"user"`
	Token string `json:"token"`
}

type User

type User struct {
	ID            int    `json:"id"`
	Name          string `json:"name"`
	Login         string `json:"login"`
	Email         string `json:"email"`
	GravatarID    string `json:"gravatar_id"`
	IsSyncing     bool   `json:"is_syncing"`
	SyncedAt      string `json:"synced_at"`
	CorrectScopes bool   `json:"correct_scopes"`
	CreatedAt     string `json:"created_at"`
}

Directories

Path Synopsis
cmd
sso

Jump to

Keyboard shortcuts

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