auth

package
v0.0.0-...-ccd08f1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthService

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

func NewAuthService

func NewAuthService(userRepo *models.UserRepository, jwtManager *JWTManager, enableOkta bool) *AuthService

func (*AuthService) AuthMiddleware

func (s *AuthService) AuthMiddleware() gin.HandlerFunc

func (*AuthService) GetOktaAuthURL

func (s *AuthService) GetOktaAuthURL(state string) (string, error)

func (*AuthService) GetUserByEmail

func (s *AuthService) GetUserByEmail(ctx context.Context, email string) (*models.User, error)

GetUserByEmail retrieves a user by their email

func (*AuthService) HandleOktaCallback

func (s *AuthService) HandleOktaCallback(ctx context.Context, code string) (string, error)

func (*AuthService) Login

func (s *AuthService) Login(ctx context.Context, email, password string) (string, error)

func (*AuthService) LoginWithOkta

func (s *AuthService) LoginWithOkta(ctx context.Context, oktaToken string) (string, error)

func (*AuthService) Register

func (s *AuthService) Register(ctx context.Context, email, password string) (string, error)

func (*AuthService) SetOktaService

func (s *AuthService) SetOktaService(oktaService *OktaService)

type Claims

type Claims struct {
	UserID  int64  `json:"user_id"`
	Email   string `json:"email"`
	IsAdmin bool   `json:"is_admin"`
	jwt.RegisteredClaims
}

func ParseToken

func ParseToken(tokenString, secret string) (*Claims, error)

type JWTManager

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

func NewJWTManager

func NewJWTManager(secretKey string, expiry time.Duration) *JWTManager

func (*JWTManager) GenerateToken

func (m *JWTManager) GenerateToken(user *models.User) (string, error)

func (*JWTManager) ValidateToken

func (m *JWTManager) ValidateToken(tokenStr string) (*Claims, error)

type OktaService

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

func NewOktaService

func NewOktaService(orgURL, clientID, clientSecret string, redirectURL string) (*OktaService, error)

func (*OktaService) ExchangeCode

func (s *OktaService) ExchangeCode(ctx context.Context, code string) (*oauth2.Token, error)

func (*OktaService) GetAuthURL

func (s *OktaService) GetAuthURL(state string) string

func (*OktaService) ValidateToken

func (s *OktaService) ValidateToken(ctx context.Context, tokenString string) (*OktaUserInfo, error)

type OktaUserInfo

type OktaUserInfo struct {
	Sub   string `json:"sub"`
	Email string `json:"email"`
	Name  string `json:"name"`
}

Jump to

Keyboard shortcuts

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