oauth

package
v1.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderGithub = "github"

	// Github API endpoints
	GithubURLAuthorize = "/login/oauth/authorize"
	GithubURLToken     = "/login/oauth/access_token"
	GithubURLUser      = "/user"
	GithubURLEmails    = "/user/emails"
)

Variables

This section is empty.

Functions

func CallbackURL

func CallbackURL(appID string) string

Types

type App

type App struct {
	ID           string
	ClientID     string
	ClientSecret string
	RedirectURL  url.URL
	AuthHost     url.URL
	APIHost      url.URL
	Provider     string
}

type AuthorizationRequest

type AuthorizationRequest struct {
	AppID    string `param:"app_id"`
	ClientID string `query:"client_id"`
	Scopes   string `query:"scopes"`
	State    string `query:"state"`
}

type CallbackRequest

type CallbackRequest struct {
	AppID string `param:"app_id"`
	Code  string `query:"code"`
	State string `query:"state"`
}

type Factory

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

func NewFactory

func NewFactory(apps map[string]*App) *Factory

func (*Factory) GetBackend

func (f *Factory) GetBackend(appID string) (IBackend, error)

type Github

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

func (*Github) AuthorizationURL

func (g *Github) AuthorizationURL(state string, scopes []string) (string, error)

func (*Github) GetToken

func (g *Github) GetToken(ctx context.Context, code string) (*oauth2.Token, error)

func (*Github) GetUser

func (g *Github) GetUser(ctx context.Context, token *oauth2.Token) (*model.User, error)

func (*Github) RefreshToken

func (g *Github) RefreshToken(_ context.Context, refreshToken string) (*oauth2.Token, error)

type Handler

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

func NewHandler

func NewHandler(runner *model.Runner, deepsource *model.DeepSource, store store.Store, tokenService *token.Service, factory *Factory) *Handler

func (*Handler) HandleAuthorize

func (h *Handler) HandleAuthorize(c echo.Context) error

func (*Handler) HandleCallback

func (h *Handler) HandleCallback(c echo.Context) error

func (*Handler) HandleRefresh

func (h *Handler) HandleRefresh(c echo.Context) error

func (*Handler) HandleSession

func (h *Handler) HandleSession(c echo.Context) error

func (*Handler) HandleToken

func (h *Handler) HandleToken(c echo.Context) error

func (*Handler) HandleUser

func (h *Handler) HandleUser(c echo.Context) error

type IBackend

type IBackend interface {
	AuthorizationURL(state string, scopes []string) (string, error)
	GetToken(ctx context.Context, code string) (*oauth2.Token, error)
	RefreshToken(ctx context.Context, refreshToken string) (*oauth2.Token, error)
	GetUser(ctx context.Context, token *oauth2.Token) (*model.User, error)
}

func NewGithub

func NewGithub(app *App) (IBackend, error)

type RefreshRequest

type RefreshRequest struct {
	AppID        string `param:"app_id"`
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	RefreshToken string `json:"refresh_token"`
}

type SessionRequest

type SessionRequest struct {
	AppID string `param:"app_id"`
	State string `query:"state"`
}

type TokenRequest

type TokenRequest struct {
	AppID        string `param:"app_id"`
	Code         string `query:"code" json:"code"`
	ClientID     string `query:"client_id" json:"client_id"`
	ClientSecret string `query:"client_secret" json:"client_secret"`
}

type UserRequest

type UserRequest struct {
	AppID       string
	AccessToken string
}

func (*UserRequest) Parse

func (r *UserRequest) Parse(c echo.Context) error

type UserResponse

type UserResponse struct {
	ID       string `json:"id"`
	UserName string `json:"username"`
	FullName string `json:"full_name"`
	Email    string `json:"email"`
}

Jump to

Keyboard shortcuts

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