jwt

package
v0.0.77 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package jwt provides JWT signing and verification methods for the Cosmos SDK. It includes functionality for creating and verifying JWT tokens using the ES256K signing method.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJWTValidation = fmt.Errorf("jwt: validation error")
)
View Source
var (
	SigningMethodES256K *signer
)

Functions

func ParseWithClaims

func ParseWithClaims(tokenString string, claims Claims, keyFunc jwt.Keyfunc, options ...jwt.ParserOption) (*jwt.Token, error)

Types

type AccessType

type AccessType string
const (
	AccessTypeFull     AccessType = "full"
	AccessTypeGranular AccessType = "granular"
	AccessTypeScoped   AccessType = "scoped"
	AccessTypeNone     AccessType = "none"
)

type Claims

type Claims struct {
	jwt.RegisteredClaims
	Version string `json:"version"`
	Leases  Leases `json:"leases"`
	// contains filtered or unexported fields
}

func (Claims) AuthorizeDeploymentIDForPermissionScope

func (c Claims) AuthorizeDeploymentIDForPermissionScope(did dtypes.DeploymentID, provider sdk.Address, scope PermissionScope) bool

func (Claims) AuthorizeForDeploymentID

func (c Claims) AuthorizeForDeploymentID(did dtypes.DeploymentID, provider sdk.Address) bool

func (Claims) AuthorizeForLeaseID

func (c Claims) AuthorizeForLeaseID(lid mtypes.LeaseID) bool

func (Claims) AuthorizeForProvider

func (c Claims) AuthorizeForProvider(acc sdk.Address) bool

func (Claims) AuthorizeLeaseIDForPermissionScope

func (c Claims) AuthorizeLeaseIDForPermissionScope(lid mtypes.LeaseID, scope PermissionScope) bool

func (Claims) IssuerAddress

func (c Claims) IssuerAddress() sdk.Address

func (*Claims) Validate

func (c *Claims) Validate() error

type JWT

type JWT interface {
}

type Leases

type Leases struct {
	Access      AccessType       `json:"access"`
	Scope       PermissionScopes `json:"scope,omitempty"`
	Permissions Permissions      `json:"permissions,omitempty"`
}

func (*Leases) Validate

func (c *Leases) Validate() error

type Permission

type Permission struct {
	Provider    sdk.AccAddress         `json:"provider"`
	Access      AccessType             `json:"access"`
	Scope       PermissionScopes       `json:"scope,omitempty"`
	Deployments []PermissionDeployment `json:"deployments,omitempty"`
}

type PermissionDeployment

type PermissionDeployment struct {
	Scope    PermissionScopes `json:"scope"`
	DSeq     uint64           `json:"dseq,omitempty"`
	GSeq     uint32           `json:"gseq,omitempty"`
	OSeq     uint32           `json:"oseq,omitempty"`
	Services []string         `json:"services,omitempty"`
}

type PermissionScope

type PermissionScope string
const (
	PermissionScopeSendManifest    PermissionScope = "send-manifest"
	PermissionScopeGetManifest     PermissionScope = "get-manifest"
	PermissionScopeLogs            PermissionScope = "logs"
	PermissionScopeShell           PermissionScope = "shell"
	PermissionScopeEvents          PermissionScope = "events"
	PermissionScopeStatus          PermissionScope = "status"
	PermissionScopeRestart         PermissionScope = "restart"
	PermissionScopeHostnameMigrate PermissionScope = "hostname-migrate"
	PermissionScopeIPMigrate       PermissionScope = "ip-migrate"
)

func (PermissionScope) String

func (s PermissionScope) String() string

type PermissionScopes

type PermissionScopes []PermissionScope

func (PermissionScopes) Has

func (c PermissionScopes) Has(scope PermissionScope) bool

func (PermissionScopes) Validate

func (c PermissionScopes) Validate() error

type Permissions

type Permissions []Permission

func (Permissions) Validate

func (p Permissions) Validate() error

type Signer

type Signer struct {
	keyring.Signer
	// contains filtered or unexported fields
}

Signer implements SignerI interface

func (Signer) GetAddress

func (s Signer) GetAddress() sdk.Address

type SignerI

type SignerI interface {
	keyring.Signer
	GetAddress() sdk.Address
}

SignerI wraps cosmos keyring and account info to provide a signer interface

func NewSigner

func NewSigner(kr keyring.Keyring, addr sdk.Address) SignerI

Jump to

Keyboard shortcuts

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