auth

package
v0.90.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTClaims

type JWTClaims struct {
	Iss       string `json:"iss"`
	Sub       string `json:"sub"`
	Aud       string `json:"aud"`
	Iat       int64  `json:"iat"`
	Nbf       int64  `json:"nbf"`
	Exp       int64  `json:"exp"`
	Namespace string `json:"namespace"`
}

type Service

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

Service handles authentication business logic

func NewService

func NewService(logger *logging.ColoredLogger, orm client.NetworkClient, signingKeyPEM string, defaultNS string) (*Service, error)

func (*Service) Base58Decode

func (s *Service) Base58Decode(input string) ([]byte, error)

Base58Decode decodes a base58-encoded string

func (*Service) CreateNonce

func (s *Service) CreateNonce(ctx context.Context, wallet, purpose, namespace string) (string, error)

CreateNonce generates a new nonce and stores it in the database

func (*Service) GenerateJWT

func (s *Service) GenerateJWT(ns, subject string, ttl time.Duration) (string, int64, error)

func (*Service) GetOrCreateAPIKey

func (s *Service) GetOrCreateAPIKey(ctx context.Context, wallet, namespace string) (string, error)

GetOrCreateAPIKey returns an existing API key or creates a new one for a wallet in a namespace

func (*Service) IssueTokens

func (s *Service) IssueTokens(ctx context.Context, wallet, namespace string) (string, string, int64, error)

IssueTokens generates access and refresh tokens for a verified wallet

func (*Service) JWKSHandler

func (s *Service) JWKSHandler(w http.ResponseWriter, r *http.Request)

func (*Service) ParseAndVerifyJWT

func (s *Service) ParseAndVerifyJWT(token string) (*JWTClaims, error)

ParseAndVerifyJWT verifies an RS256 JWT created by this gateway and returns claims

func (*Service) RefreshToken

func (s *Service) RefreshToken(ctx context.Context, refreshToken, namespace string) (string, string, int64, error)

RefreshToken validates a refresh token and issues a new access token

func (*Service) RegisterApp

func (s *Service) RegisterApp(ctx context.Context, wallet, namespace, name, publicKey string) (string, error)

RegisterApp registers a new client application

func (*Service) ResolveNamespaceID

func (s *Service) ResolveNamespaceID(ctx context.Context, ns string) (interface{}, error)

ResolveNamespaceID ensures the given namespace exists and returns its primary key ID.

func (*Service) RevokeToken

func (s *Service) RevokeToken(ctx context.Context, namespace, token string, all bool, subject string) error

RevokeToken revokes a specific refresh token or all tokens for a subject

func (*Service) VerifySignature

func (s *Service) VerifySignature(ctx context.Context, wallet, nonce, signature, chainType string) (bool, error)

VerifySignature verifies a wallet signature for a given nonce

Jump to

Keyboard shortcuts

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