auth

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTTokenService

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

func NewJWTTokenService

func NewJWTTokenService(opt Options) (*JWTTokenService, error)

func (*JWTTokenService) Issue

func (s *JWTTokenService) Issue(ctx context.Context, claims contractAuth.Claims, ttlSeconds int) (string, error)

func (*JWTTokenService) Options

func (s *JWTTokenService) Options() Options

func (*JWTTokenService) Parse

func (s *JWTTokenService) Parse(ctx context.Context, tokenString string) (contractAuth.Claims, error)

type JwtServiceProvider

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

func (*JwtServiceProvider) Boot

func (p *JwtServiceProvider) Boot(ctx context.Context) error

func (*JwtServiceProvider) Conf

func (p *JwtServiceProvider) Conf() map[string]string

func (*JwtServiceProvider) Description

func (p *JwtServiceProvider) Description() string

func (*JwtServiceProvider) Register

func (p *JwtServiceProvider) Register(ctx context.Context) error

func (*JwtServiceProvider) SetApplication

func (p *JwtServiceProvider) SetApplication(app foundation.Application)

type Options

type Options struct {
	Secret    string `json:"secret"`
	Issuer    string `json:"issuer"`
	AccessTTL int    `json:"access-ttl"`
	Header    string `json:"header"`
	Prefix    string `json:"prefix"`
	Algorithm string `json:"algorithm"`
}

type TokenAuthorizer

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

TokenAuthorizer 基于 TokenService 做认证;可选 Casbin 做授权。

func NewTokenAuthorizer

func NewTokenAuthorizer(tokens contractAuth.TokenService, enforcer *casbin.SyncedEnforcer) *TokenAuthorizer

func (*TokenAuthorizer) Authenticate

func (a *TokenAuthorizer) Authenticate(ctx context.Context, rawToken string) (contractAuth.Claims, error)

func (*TokenAuthorizer) Authorize

func (a *TokenAuthorizer) Authorize(ctx context.Context, claims contractAuth.Claims, permission string) error

func (*TokenAuthorizer) IsSuperAdmin

func (a *TokenAuthorizer) IsSuperAdmin(claims contractAuth.Claims) bool

Source Files

  • jwt_service_provider.go
  • jwt_token_service.go
  • options.go
  • token_authorizer.go

Jump to

Keyboard shortcuts

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