auth

package
v0.0.0-...-232a396 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2018 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAPIKey

func GetAPIKey(c echo.Context) error

func GetSelf

func GetSelf(c echo.Context) error

func GetStore

func GetStore() *mongostore.MongoStore

func GoogleAuthCallback

func GoogleAuthCallback(c echo.Context) error

func GoogleAuthLogin

func GoogleAuthLogin(c echo.Context) error

func HandleUser

func HandleUser(c echo.Context, user goth.User) bson.ObjectId

func InitOauth

func InitOauth(dbAddress string, dbName string)

func IsAuthorized

func IsAuthorized(c echo.Context, path string) bool

IsAuthorized checks the session included in the request. If the user is not authorized for the given request, returns false and makes an appropriate response with the context. Otherwise, returns true and defers responses to the caller. If the user is authorized for a given endpoint, IsAuthorized extends the session's expiration.

func Logout

func Logout(c echo.Context) error

func ResetAPIKey

func ResetAPIKey(c echo.Context) error

Types

type APIUser

type APIUser struct {
	ID    bson.ObjectId `json:"_id"`
	Email string        `json:"email"`
	Roles []*Role       `json:"roles"`
}

type Permission

type Permission struct {
	Path     string `bson:"path" json:"path"`
	CanRead  bool   `bson:"canRead" json:"canRead"`
	CanWrite bool   `bson:"canWrite" json:"canWrite"`
}

type Role

type Role struct {
	ID          bson.ObjectId `bson:"_id" json:"id"`
	Name        string        `bson:"name" json:"name"`
	Permissions []Permission  `bson:"permissions" json:"permissions"`
}

type Session

type Session struct {
	ID        bson.ObjectId `bson:"_id,omitempty"`
	User      User          `bson:"user"`
	UserInfo  goth.User     `bson:"userInfo"`
	Token     string        `bson:"token"`
	CreatedAt time.Time     `bson:"created"`
	ExpiresAt time.Time     `bson:"expiry"`
}

type User

type User struct {
	ID    bson.ObjectId   `bson:"_id"`
	Email string          `bson:"email"`
	Roles []bson.ObjectId `bson:"roles"`
}

Jump to

Keyboard shortcuts

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