identity

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2017 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//OAuthFacebookProvider is const for 'facebook'
	OAuthFacebookProvider = "facebook"
	//OAuthGoogleProvider is const for 'google'
	OAuthGoogleProvider = "google"
)

Variables

This section is empty.

Functions

func Decode

func Decode(token string) (*app.WechyClaims, error)

Decode extract claims from JWT tokens

func Encode

func Encode(claims *app.WechyClaims) (string, error)

Encode creates new JWT tokens with given claims

func HostChecker

func HostChecker(baseURL string) app.MiddlewareFunc

HostChecker checks for a specific host

func JwtGetter

func JwtGetter() app.MiddlewareFunc

JwtGetter gets JWT token from cookie and add into context

func JwtSetter

func JwtSetter() app.MiddlewareFunc

JwtSetter sets JWT token into cookie

func MultiTenant

func MultiTenant(tenantService TenantService) app.MiddlewareFunc

MultiTenant extract tenant information from hostname and inject it into current context

Types

type HTTPOAuthService

type HTTPOAuthService struct{}

HTTPOAuthService implements real OAuth operations using Golang's oauth2 package

func (HTTPOAuthService) GetAuthURL

func (p HTTPOAuthService) GetAuthURL(provider string, redirect string) string

GetAuthURL returns authentication url for given provider

func (HTTPOAuthService) GetProfile

func (p HTTPOAuthService) GetProfile(provider string, code string) (*OAuthUserProfile, error)

GetProfile returns user profile based on provider and code

type OAuthHandlers

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

OAuthHandlers contains multiple oauth HTTP handlers

func OAuth

func OAuth(oauthService OAuthService, userService UserService) OAuthHandlers

OAuth creates a new OAuthHandlers

func (OAuthHandlers) Callback

func (h OAuthHandlers) Callback(provider string) app.HandlerFunc

Callback handles OAuth callbacks

func (OAuthHandlers) Login

func (h OAuthHandlers) Login(provider string) app.HandlerFunc

Login handles OAuth logins

func (OAuthHandlers) Logout

func (h OAuthHandlers) Logout() app.HandlerFunc

Logout remove auth cookies

type OAuthService

type OAuthService interface {
	GetAuthURL(provider string, redirect string) string
	GetProfile(provider string, code string) (*OAuthUserProfile, error)
}

OAuthService provides OAuth operations

type OAuthUserProfile

type OAuthUserProfile struct {
	ID    string
	Name  string
	Email string
}

OAuthUserProfile represents an OAuth user profile

type TenantService

type TenantService interface {
	GetByDomain(domain string) (*app.Tenant, error)
}

TenantService contains read and write operations for tenants

type UserService

type UserService interface {
	GetByEmail(email string) (*app.User, error)
	Register(user *app.User) error
}

UserService is used for user operations

Jump to

Keyboard shortcuts

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