Back to godoc.org

Package auth

v0.7.0
Latest Go to latest

The latest major version is .

Published: Jul 8, 2018 | License: GPL3 | Module: github.com/artpar/goms

Index

Constants

const (
	Read    = ReadStrict | Peek
	Refer   = ReferStrict | Read
	Create  = CreateStrict | Read
	Update  = UpdateStrict | Read
	Delete  = DeleteStrict | Read
	Execute = ExecuteStrict | Peek
	CRUD    = Read | Create | Update | Delete | Refer
)

Variables

var ALLOW_ALL_PERMISSIONS = NewPermission(CRUD|Execute, CRUD|Execute, CRUD|Execute)
var DEFAULT_PERMISSION = NewPermission(Peek|Refer, CRUD|Execute, CRUD|Execute)

func BcryptCheckStringHash

func BcryptCheckStringHash(newString, hash string) bool

func CheckErr

func CheckErr(err error, message ...interface{})

func InitJwtMiddleware

func InitJwtMiddleware(secret []byte, issuer string)

func StartsWith

func StartsWith(bigStr string, smallString string) bool

type AuthMiddleware

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

func NewAuthMiddleware

func NewAuthMiddleware(db database.DatabaseConnection, userCrud ResourceAdapter, userGroupCrud ResourceAdapter, userUserGroupCrud ResourceAdapter) *AuthMiddleware

func NewAuthMiddlewareBuilder

func NewAuthMiddlewareBuilder(db database.DatabaseConnection, issuer string) *AuthMiddleware

func (*AuthMiddleware) AuthCheckMiddleware

func (a *AuthMiddleware) AuthCheckMiddleware(c *gin.Context)

func (*AuthMiddleware) AuthCheckMiddlewareWithHttp

func (a *AuthMiddleware) AuthCheckMiddlewareWithHttp(req *http.Request, writer http.ResponseWriter, doBasicAuthCheck bool) (okToContinue, abortRequest bool, returnRequest *http.Request)

func (*AuthMiddleware) BasicAuthCheckMiddlewareWithHttp

func (a *AuthMiddleware) BasicAuthCheckMiddlewareWithHttp(req *http.Request, writer http.ResponseWriter) (token *jwt.Token, err error)

func (*AuthMiddleware) SetUserCrud

func (a *AuthMiddleware) SetUserCrud(curd ResourceAdapter)

func (*AuthMiddleware) SetUserGroupCrud

func (a *AuthMiddleware) SetUserGroupCrud(curd ResourceAdapter)

func (*AuthMiddleware) SetUserUserGroupCrud

func (a *AuthMiddleware) SetUserUserGroupCrud(curd ResourceAdapter)

type AuthPermission

type AuthPermission int64
const (
	Peek AuthPermission = 1 << iota
	ReadStrict
	CreateStrict
	UpdateStrict
	DeleteStrict
	ExecuteStrict
	ReferStrict
)
const None AuthPermission = iota

func (AuthPermission) String

func (a AuthPermission) String() string

type CmsUser

type CmsUser interface {
	GetName() string
	GetEmail() string
	IsGuest() bool
	IsLoggedIn() bool
}

type GroupPermission

type GroupPermission struct {
	GroupReferenceId    string `db:"GroupReferenceId"`
	ObjectReferenceId   string `db:"ObjectReferenceId"`
	RelationReferenceId string `db:"RelationReferenceId"`
	Permission          ObjectPermission
}

type ObjectPermission

type ObjectPermission struct {
	OwnerPermission AuthPermission
	GroupPermission AuthPermission
	GuestPermission AuthPermission
}

func NewPermission

func NewPermission(guest AuthPermission, group AuthPermission, owner AuthPermission) ObjectPermission

func ParsePermission

func ParsePermission(p int64) ObjectPermission

func (ObjectPermission) GroupCan

func (op ObjectPermission) GroupCan(a AuthPermission) bool

func (ObjectPermission) GuestCan

func (op ObjectPermission) GuestCan(a AuthPermission) bool

func (ObjectPermission) IntValue

func (al ObjectPermission) IntValue() int64

func (ObjectPermission) OwnerCan

func (op ObjectPermission) OwnerCan(a AuthPermission) bool

func (*ObjectPermission) Scan

func (op *ObjectPermission) Scan(value interface{}) error

func (ObjectPermission) String

func (al ObjectPermission) String() string

func (ObjectPermission) Value

func (op ObjectPermission) Value() (driver.Value, error)

type ResourceAdapter

type ResourceAdapter interface {
	api2go.CRUD
	GetUserPassword(email string) (string, error)
}

type SessionUser

type SessionUser struct {
	UserId          int64
	UserReferenceId string
	Groups          []GroupPermission
}

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier