auth

package
v0.0.0-...-c297032 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2022 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetServer

func GetServer() *server.Server

Types

type GitHubUser

type GitHubUser struct {
	Email     string `json:"email"`
	Login     string `json:"login"`
	Id        int    `json:"id"`
	AvatarUrl string `json:"avatar_url"`
}

type GithubAuthApi

type GithubAuthApi struct {
	ConfGitHub *oauth2.Config
	Repo       repository.UserRepo
	// contains filtered or unexported fields
}

func ProvideGithubAuth

func ProvideGithubAuth(repo repository.UserRepo, awsService *aws.AWSService, jwtService *jwt.TokenService) *GithubAuthApi

func (*GithubAuthApi) AuthorizeGithub

func (api *GithubAuthApi) AuthorizeGithub(c *gin.Context)
AuthorizeGithub

generate github authorize url and redirect directly

func (*GithubAuthApi) AuthorizeGithubUrl

func (api *GithubAuthApi) AuthorizeGithubUrl(c *gin.Context)

AuthorizeGithubUrl generate github authorize url and return url

func (*GithubAuthApi) CheckNativeToken

func (api *GithubAuthApi) CheckNativeToken(c *gin.Context)

CheckNativeToken - verify native token

func (*GithubAuthApi) GetGithubToken

func (api *GithubAuthApi) GetGithubToken(c *gin.Context)

GetGithubToken

redirect from github with code, call github api again in backend (for security reason), get access token generated by github

*

func (*GithubAuthApi) GetNativeToken

func (api *GithubAuthApi) GetNativeToken(c *gin.Context)

GetNativeToken - Get github user info and register into to our database, finally generate native jwt token

  1. get github user
  2. check native user by email 2.1 update native user -- email exists 2.2 add native user -- email not exists 3 generate jwt token 4 return token

func (*GithubAuthApi) Login

func (api *GithubAuthApi) Login(c *gin.Context)

a combined API to get native token by auth code from github:

  1. use github auth code + state to get github token;
  2. use github token to get github user info;
  3. ensure github user email registered in our system;
  4. register new user if not already exists;
  5. generate token with our own signature.

type InternalAuthApi

type InternalAuthApi struct {
	NativeServer *server.Server
	// contains filtered or unexported fields
}

func ProvideInternalAuthApi

func ProvideInternalAuthApi(awsService *aws.AWSService) *InternalAuthApi

func (*InternalAuthApi) ClientSecretLogin

func (api *InternalAuthApi) ClientSecretLogin(c *gin.Context)

func (*InternalAuthApi) GetRedirectUrl

func (api *InternalAuthApi) GetRedirectUrl(c *gin.Context)

func (*InternalAuthApi) GetToken

func (api *InternalAuthApi) GetToken(c *gin.Context)

func (*InternalAuthApi) PassordLogin

func (api *InternalAuthApi) PassordLogin(c *gin.Context)

func (*InternalAuthApi) RefreshToken

func (api *InternalAuthApi) RefreshToken(c *gin.Context)

func (*InternalAuthApi) TestAccess

func (api *InternalAuthApi) TestAccess(c *gin.Context)

Jump to

Keyboard shortcuts

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