services

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2025 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CharSet = "UTF-8" // Character Set
)

Variables

View Source
var (
	ErrInvalidKey     = errors.New("invalid key format")
	ErrExpiredKey     = errors.New("key has expired")
	ErrInvalidPayload = errors.New("invalid payload")
)

Functions

func SendEmail

func SendEmail(ctx context.Context, _awsConfig aws.Config, req *models.EmailSendRequest) error

func SendTeamAddEmail

func SendTeamAddEmail(ctx context.Context, _awsConfig aws.Config, req *models.EmailSendRequest) error

Types

type APIKeyManager

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

APIKeyManager handles API key operations with optimized performance

func NewAPIKeyManager

func NewAPIKeyManager(cfg *models.Config, driver interfaces.ApitoSystemDB) (*APIKeyManager, error)

func NewAPIKeyManagerNoDB

func NewAPIKeyManagerNoDB(cfg *models.Config) (*APIKeyManager, error)

func (*APIKeyManager) GenerateKey

func (m *APIKeyManager) GenerateKey(payload *models.TokenClaims) (string, error)

func (*APIKeyManager) GenerateTenantToken

func (m *APIKeyManager) GenerateTenantToken(ctx context.Context, tenantID, token string) (string, error)

func (*APIKeyManager) Validate

func (m *APIKeyManager) Validate(ctx context.Context, key string, skipDBCheck bool) (*models.TokenClaims, error)

func (*APIKeyManager) ValidateAndSetContext

func (m *APIKeyManager) ValidateAndSetContext(c echo.Context, token string) (*models.TokenClaims, error)

type APIKeyMock

type APIKeyMock struct {
	Val []byte
}

func (APIKeyMock) Value

func (k APIKeyMock) Value() []byte

type ApitoTokenService

type ApitoTokenService struct {
	Batch *goBatch.Batch[models.ProjectApiTracking]
	// contains filtered or unexported fields
}

func (*ApitoTokenService) ApitoPublicFunctionRouteHandler

func (t *ApitoTokenService) ApitoPublicFunctionRouteHandler(next echo.HandlerFunc) echo.HandlerFunc

func (*ApitoTokenService) ApitoTokenHandler

func (t *ApitoTokenService) ApitoTokenHandler(next echo.HandlerFunc) echo.HandlerFunc

func (*ApitoTokenService) Shutdown added in v1.1.6

func (t *ApitoTokenService) Shutdown() error

Shutdown gracefully stops the batch processor

type AuthServiceInterface

type AuthServiceInterface interface {
	Login(ctx context.Context, req *models.LoginRequest, user *models.SystemUser, projectWithRoles *models.ProjectWithRoles) (*models.JWTTokens, error)

	Signup(ctx context.Context, req *models.RegisterRequest) (*models.SystemUser, error)
	ConfirmSignup(ctx context.Context, req *models.RegisterRequest) error

	ForgetPasswordRequest(ctx context.Context, req *models.RegisterRequest) error
	ConfirmForgetPassword(ctx context.Context, req *models.RegisterRequest) error

	ChangePassword(ctx context.Context, user *models.SystemUser, old, new string) (*models.SystemUser, error)

	Logout(ctx context.Context, token string) error

	VerifyIDToken(ctx context.Context, token string) (*models.TokenClaims, error)
	VerifyAccessToken(ctx context.Context, token string) error

	ExchangeAndRefreshToken(ctx context.Context, projectWithRoles *models.ProjectWithRoles) (*models.JWTTokens, error)
}

type BrankaToken

type BrankaToken struct {
	Token *branca.Branca
	// contains filtered or unexported fields
}

func GetBrankaToken

func GetBrankaToken(cfg *models.Config, db interfaces.ApitoSystemDB) *BrankaToken

func (*BrankaToken) GenerateAPIKey

func (t *BrankaToken) GenerateAPIKey(ctx context.Context, userID, projectID, tenantID, tokenType string, expireAt int64) (*string, error)

func (*BrankaToken) GenerateProjectToken

func (t *BrankaToken) GenerateProjectToken(claims *models.TokenClaims, ttl uint32) (*string, error)

func (*BrankaToken) Validate

func (t *BrankaToken) Validate(ctx context.Context, token string) (*models.TokenClaims, error)

func (*BrankaToken) ValidateAndSetContext

func (t *BrankaToken) ValidateAndSetContext(c echo.Context, token string) (*models.TokenClaims, error)

type CustomResponseWriter

type CustomResponseWriter struct {
	http.ResponseWriter
	Body   *bytes.Buffer
	Status int
}

CustomResponseWriter is a wrapper around the standard http.ResponseWriter that captures the status code and response body.

func (*CustomResponseWriter) Header

func (w *CustomResponseWriter) Header() http.Header

Header returns the header map that will be sent by WriteHeader.

func (*CustomResponseWriter) Write

func (w *CustomResponseWriter) Write(b []byte) (int, error)

Write captures the response body and calls the underlying Write.

func (*CustomResponseWriter) WriteHeader

func (w *CustomResponseWriter) WriteHeader(code int)

WriteHeader captures the status code and calls the underlying WriteHeader.

type DBMock

type DBMock struct {
	typederrs.NotFoundErrCheck

	ExpInsAPIKErr        error
	ExpAPIKBUsrIDVal     api.Key
	ExpAPIKsBUsrIDValErr error
	RecInsAPIKUsrID      string
}

func (*DBMock) APIKeyByUserIDVal

func (db *DBMock) APIKeyByUserIDVal(userID string, key []byte) (api.Key, error)

func (*DBMock) InsertAPIKey

func (db *DBMock) InsertAPIKey(userID string, key []byte) (api.Key, error)

type JWTService

type JWTService struct {
	Cfg        *models.Config
	PrivateKey *rsa.PrivateKey
	PublicKey  *rsa.PublicKey
	// contains filtered or unexported fields
}

func GetJWTService

func GetJWTService(cfg *models.Config) (*JWTService, error)

func GetJWTServiceWithNoSqlDb

func GetJWTServiceWithNoSqlDb(cfg *models.Config) *JWTService

func GetJWTServiceWithRedis

func GetJWTServiceWithRedis(cfg *models.Config, kvService interfaces.KeyValueServiceInterface) *JWTService

func (*JWTService) ChangePassword

func (s *JWTService) ChangePassword(ctx context.Context, token, old, new string) error

func (*JWTService) ConfirmForgetPassword

func (s *JWTService) ConfirmForgetPassword(ctx context.Context, req *models.RegisterRequest) error

func (*JWTService) ConfirmSignup

func (s *JWTService) ConfirmSignup(ctx context.Context, req *models.RegisterRequest) error

func (*JWTService) ExchangeAndRefreshToken

func (t *JWTService) ExchangeAndRefreshToken(ctx context.Context, user *models.SystemUser) (*models.JWTTokens, error)

no use at this time

func (*JWTService) ForgetPasswordRequest

func (s *JWTService) ForgetPasswordRequest(ctx context.Context, req *models.RegisterRequest) error

func (*JWTService) GenerateIdToken

func (s *JWTService) GenerateIdToken(param *models.CommonSystemParams) (*string, error)

func (*JWTService) GenerateLoginAccessToken

func (s *JWTService) GenerateLoginAccessToken(ctx context.Context) (*string, error)

func (*JWTService) GenerateLoginIDToken

func (s *JWTService) GenerateLoginIDToken(ctx context.Context, projectWithRoles *models.ProjectWithRoles) (*string, error)

func (*JWTService) GenerateLoginRefreshToken

func (s *JWTService) GenerateLoginRefreshToken(projectWithRoles *models.ProjectWithRoles) (*string, error)

func (*JWTService) GenerateLoginToken

func (s *JWTService) GenerateLoginToken(ctx context.Context, projectWithRoles *models.ProjectWithRoles) (*models.JWTTokens, error)

func (*JWTService) GenerateRandomString

func (s *JWTService) GenerateRandomString(n int) string

func (*JWTService) GenerateRefreshToken

func (s *JWTService) GenerateRefreshToken(param *models.CommonSystemParams, month int) (*string, error)

func (*JWTService) Invalidate

func (s *JWTService) Invalidate(tokenString string) error

func (*JWTService) IsInBlacklist

func (s *JWTService) IsInBlacklist(token string) bool

func (*JWTService) Login

func (*JWTService) Logout

func (s *JWTService) Logout(ctx context.Context, token string) error

func (*JWTService) Signup

func (s *JWTService) Signup(ctx context.Context, req *models.RegisterRequest) error

func (*JWTService) Validate

func (s *JWTService) Validate(tokenObj bool, tokenString string) (bool, error)

func (*JWTService) VerifyAccessToken

func (s *JWTService) VerifyAccessToken(ctx context.Context, token string) error

func (*JWTService) VerifyIDToken

func (s *JWTService) VerifyIDToken(ctx context.Context, token string) (*models.TokenClaims, error)

type KeyGenMock

type KeyGenMock struct {
	ExpSRBsErr error
	ExpSRBs    []byte
}

func (*KeyGenMock) SecureRandomBytes

func (kg *KeyGenMock) SecureRandomBytes(length int) ([]byte, error)

type LocalAuthService

type LocalAuthService struct {
	TokenService *JWTService
}

func NewLocalAuthService

func NewLocalAuthService(cfg *models.Config, tokenService *JWTService) (*LocalAuthService, error)

func (*LocalAuthService) ChangePassword

func (l *LocalAuthService) ChangePassword(ctx context.Context, user *models.SystemUser, old, new string) (*models.SystemUser, error)

func (*LocalAuthService) ConfirmForgetPassword

func (l *LocalAuthService) ConfirmForgetPassword(ctx context.Context, req *models.RegisterRequest) error

func (*LocalAuthService) ConfirmSignup

func (l *LocalAuthService) ConfirmSignup(ctx context.Context, req *models.RegisterRequest) error

func (*LocalAuthService) ExchangeAndRefreshToken

func (l *LocalAuthService) ExchangeAndRefreshToken(ctx context.Context, projectWithRoles *models.ProjectWithRoles) (*models.JWTTokens, error)

func (*LocalAuthService) ForgetPasswordRequest

func (l *LocalAuthService) ForgetPasswordRequest(ctx context.Context, req *models.RegisterRequest) error

func (*LocalAuthService) Login

func (*LocalAuthService) Logout

func (l *LocalAuthService) Logout(ctx context.Context, token string) error

func (*LocalAuthService) Signup

func (l *LocalAuthService) Signup(ctx context.Context, registerRequest *models.RegisterRequest) (*models.SystemUser, error)

func (*LocalAuthService) VerifyAccessToken

func (l *LocalAuthService) VerifyAccessToken(ctx context.Context, token string) error

func (*LocalAuthService) VerifyIDToken

func (l *LocalAuthService) VerifyIDToken(ctx context.Context, token string) (*models.TokenClaims, error)

type TokenService

type TokenService struct {
	Guard *api.Guard
}

func GetTokenService

func GetTokenService(cfg *models.Config) *TokenService

func GetTokenServiceWithRedis

func GetTokenServiceWithRedis(cfg *models.Config) *TokenService

func (*TokenService) GenerateProjectToken

func (t *TokenService) GenerateProjectToken(user *models.SystemUser, projectId string) (string, error)

func (*TokenService) Validate

func (t *TokenService) Validate(cfg *models.Config, token string) (*models.TokenClaims, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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