Documentation
¶
Index ¶
- Constants
- func Decode(token string) (*app.WechyClaims, error)
- func Encode(claims *app.WechyClaims) (string, error)
- func HostChecker(baseURL string) app.MiddlewareFunc
- func JwtGetter() app.MiddlewareFunc
- func JwtSetter() app.MiddlewareFunc
- func MultiTenant(tenantService TenantService) app.MiddlewareFunc
- type HTTPOAuthService
- type OAuthHandlers
- type OAuthService
- type OAuthUserProfile
- type TenantService
- type UserService
Constants ¶
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 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 ¶
OAuthUserProfile represents an OAuth user profile
type TenantService ¶
TenantService contains read and write operations for tenants