oauth

package
v0.0.0-...-100be9c Latest Latest
Warning

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

Go to latest
Published: May 7, 2018 License: BSD-2-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderGoogle    = "google"
	GoogleURL         = "https://www.googleapis.com/oauth2/v2/userinfo?access_token=%s"
	ProviderAmazon    = "amazon"
	AmazonURL         = "https://api.amazon.com/user/profile?access_token=%s"
	ProviderMicrosoft = "microsoft"
	MicrosoftURL      = "https://apis.live.net/v5.0/me?access_token=%s"
)

Variables

This section is empty.

Functions

func AuthFromGrpcContext

func AuthFromGrpcContext() grpctransport.ClientRequestFunc

func AuthGuard

func AuthGuard(next http.Handler) http.HandlerFunc

func AuthToGrpcContext

func AuthToGrpcContext() grpctransport.ServerRequestFunc

func BasicAuthGuard

func BasicAuthGuard(next http.Handler) http.HandlerFunc

func BasicAuthToHTTPContext

func BasicAuthToHTTPContext() httptransport.RequestFunc

func BasicAuthToHTTPRequest

func BasicAuthToHTTPRequest(username, password string) httptransport.RequestFunc

func CookieToHTTPContext

func CookieToHTTPContext(logger log.Logger, keyFunc stdjwt.Keyfunc, sc *securecookie.SecureCookie) httptransport.RequestFunc

func CookieToHTTPRequest

func CookieToHTTPRequest() httptransport.RequestFunc

func FromGrpcContext

func FromGrpcContext() grpctransport.ClientRequestFunc

func JwtAuthGuard

func JwtAuthGuard(next http.Handler) http.HandlerFunc

func LoginCookieToHTTPContext

func LoginCookieToHTTPContext(logger log.Logger, keyFunc stdjwt.Keyfunc, sc *securecookie.SecureCookie) httptransport.RequestFunc

func MakeClaimsToken

func MakeClaimsToken(uid string) *stdjwt.Token

func MakeRefreshToken

func MakeRefreshToken(_, uid, role string, key []byte) (string, error)

func MakeToken

func MakeToken(_, uid, name, email string, key []byte) (string, error)

func StreamIntercepter

func StreamIntercepter(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

func ToGrpcContext

func ToGrpcContext() grpctransport.ServerRequestFunc

func UnaryIntercepter

func UnaryIntercepter(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

Types

type AmazonResponse

type AmazonResponse struct {
	UserID string `json:"user_id"`
	Email  string `json:"email"`
	Name   string `json:"name"`
}

type CustomClaims

type CustomClaims struct {
	//Kid      string `json:"kid"`
	Username string `json:"username"`
	Email    string `json:"email"`
	Role     string `json:"role"`
	stdjwt.StandardClaims
}

func (CustomClaims) Valid

func (c CustomClaims) Valid() error

func (CustomClaims) VerifyUsername

func (c CustomClaims) VerifyUsername(u string) bool

type GoogleResponse

type GoogleResponse struct {
	ID            string `json:"id"`
	Email         string `json:"email"`
	VerifiedEmail bool   `json:"verified_email"`
	Name          string `json:"name"`
	Picture       string `json:"picture"`
	Locale        string `json:"locale"`
}

type MicrosoftResponse

type MicrosoftResponse struct {
	ID     string            `json:"id"`
	Name   string            `json:"name"`
	UserID string            `json:"user_id"`
	Emails map[string]string `json:"emails"`
}

type Provider

type Provider interface {
	GetLoginURL(state string) (url string)
	// TODO
	LoginUser(state, code string) (*UserInfo, error)
}

func NewProviderAmazon

func NewProviderAmazon(
	redirectURL string,
	clientId string,
	clientSecret string,
) Provider

func NewProviderGoogle

func NewProviderGoogle(
	redirectURL string,
	clientId string,
	clientSecret string,
) Provider

func NewProviderMicrosoft

func NewProviderMicrosoft(
	redirectURL string,
	clientId string,
	clientSecret string,
) Provider

type UserInfo

type UserInfo struct {
	Name       string
	Email      string
	ProviderId string
	PictureUrl string
}

Jump to

Keyboard shortcuts

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