jwt

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 13 Imported by: 1

README

JWT ENCODING

JWT Authorizations。

Install

go get github.com/aacfactory/fns-contrib/authorizations/encoding/jwt

Usage

Config
authorization:
  encoding:
    method: "RS512"
    publicKey: "path of public key"
    privateKey: "path of private key"
    issuer: ""
    audience:
      - foo
      - bar
    expirations: "720h0m0s"
Register encoding
import (
    "github.com/aacfactory/fns-contrib/authorizations/encoding/jwt"
)


authorizations.Service(jwt.Component())

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Component added in v1.0.0

func Component() (component service.Component)

Types

type Claims

type Claims struct {
	gwt.RegisteredClaims
	Attr *json.Object `json:"attr"`
}

type Config

type Config struct {
	Method      string   `json:"method,omitempty"`
	SK          string   `json:"sk,omitempty"`
	PublicKey   string   `json:"publicKey,omitempty"`
	PrivateKey  string   `json:"privateKey,omitempty"`
	Issuer      string   `json:"issuer,omitempty"`
	Audience    []string `json:"audience,omitempty"`
	Expirations string   `json:"expirations,omitempty"`
}

type Token

type Token struct {
	Claims *Claims
	// contains filtered or unexported fields
}

func (*Token) Bytes

func (t *Token) Bytes() (p []byte)

func (*Token) Id

func (t *Token) Id() (id string)

func (*Token) NotAfter

func (t *Token) NotAfter() (date time.Time)

func (*Token) NotBefore

func (t *Token) NotBefore() (date time.Time)

func (*Token) User

func (t *Token) User() (id string, attr *json.Object)

Jump to

Keyboard shortcuts

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