auth

package
v0.0.0-...-50b1eba Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleOAuth2Callback

func HandleOAuth2Callback(w http.ResponseWriter, r *http.Request)

HandleOAuth2Callback handles the OAuth2 Callback and get user info

func HandleOAuth2Login

func HandleOAuth2Login(w http.ResponseWriter, r *http.Request)

HandleOAuth2Login handles the OAuth2 login

func Init

func Init()

Init initialize the configuration

func InitSM

func InitSM(sm *scs.SessionManager)

InitSM init the current package with the provided SCS session manager

func Logout

func Logout(w http.ResponseWriter, r *http.Request)

Logout remove the user from the cookie store

func SendUser

func SendUser(w http.ResponseWriter, r *http.Request)

SendUser returns the user found from the request into the store

Types

type Auth

type Auth struct {
	AuthLoginURL  string
	AuthLogoutURL string
}

Auth implements the qor Auth interface, and can be used in an admin (https://doc.getqor.com/admin/authentication.html, https://godoc.org/github.com/qor/admin#Auth)

func (Auth) GetCurrentUser

func (a Auth) GetCurrentUser(c *admin.Context) qor.CurrentUser

GetCurrentUser returns the current user from the context

func (Auth) LoginURL

func (a Auth) LoginURL(c *admin.Context) string

LoginURL gets the login url for the admin to redirect on auth error (no user)

func (Auth) LogoutURL

func (a Auth) LogoutURL(c *admin.Context) string

LogoutURL sets the logout url that is inserted into the admin page

type User

type User struct {
	Login    string   `json:"login"`
	FullName string   `json:"displayName,omitempty"`
	MemberOf []string `json:"memberOf"`
	IsAdmin  bool     `json:"isAdmin"`
	Name     string   `json:"name,omitempty"`
	Email    string   `json:"email,omitempty"`
}

User struct implements the QOR qor.CurrentUser interface https://godoc.org/github.com/qor/qor#CurrentUser

func GetUser

func GetUser(r *http.Request) (User, error)

GetUser gets an user from a request

func (User) DisplayName

func (u User) DisplayName() string

DisplayName returns the user full name

func (User) IsMemberOf

func (u User) IsMemberOf(group string) bool

IsMemberOf checks if an user is a member of the given group

Jump to

Keyboard shortcuts

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