oauth

package
v0.0.0-...-4ba1516 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const AuthHeaderName = "Authorization"
View Source
const CookieName = "highlightOAuth"
View Source
const CookieRefreshThreshold = 15 * time.Minute

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

func CreateServer

func CreateServer(ctx context.Context, db *gorm.DB, rd *hredis.Client) (*Server, error)

func (*Server) ClientInfoHandler

func (s *Server) ClientInfoHandler(r *http.Request) (clientID, clientSecret string, err error)

ClientInfoHandler provides the clientID and clientSecret based on the request. The data either exists in the `Authorization` header or in a query parameter for SPAs where the secret must be retrieved from our database.

func (*Server) HandleAuthorizeRequest

func (s *Server) HandleAuthorizeRequest(w http.ResponseWriter, r *http.Request)

HandleAuthorizeRequest will process a request for oauth /authorize command per the RFC spec.

func (*Server) HandleRevoke

func (s *Server) HandleRevoke(w http.ResponseWriter, r *http.Request)

HandleRevoke will revoke the oauth token for header or cookie authentication.

func (*Server) HandleTokenRequest

func (s *Server) HandleTokenRequest(w http.ResponseWriter, r *http.Request)

HandleTokenRequest will process a request for oauth /token command per the RFC spec.

func (*Server) HandleValidate

func (s *Server) HandleValidate(w http.ResponseWriter, r *http.Request)

HandleValidate will ensure the request authorization is valid and return oauth session metadata.

func (*Server) HasBearer

func (s *Server) HasBearer(r *http.Request) bool

func (*Server) HasCookie

func (s *Server) HasCookie(r *http.Request) bool

func (*Server) UserAuthorizationHandler

func (s *Server) UserAuthorizationHandler(_ http.ResponseWriter, r *http.Request) (userID string, err error)

UserAuthorizationHandler provides the user ID for further `model.Admin` resolution based on the firebase session. This method is used during the OAuth token creation to associate a token with the firebase user.

func (*Server) Validate

func (s *Server) Validate(ctx context.Context, r *http.Request) (context.Context, oauth2.TokenInfo, *http.Cookie, error)

Validate ensures the request is authenticated and configures the context to contain necessary authorization context variables. the function returns the auth token cookie, refreshed if applicable.

type Token

type Token struct {
	AccessToken  string
	ExpiresIn    int64
	Scope        string
	RefreshToken string
}

Jump to

Keyboard shortcuts

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