New (token/jwt.go)

go-micro · auth/jwt/token/jwt.go · go · Apache-2.0
auth

Module exposing: New, Generate, Inspect, String, authClaims, JWT

// Source: https://github.com/micro/go-micro | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package token

import (
	"encoding/base64"
	"time"

	"github.com/golang-jwt/jwt/v5"
	"go-micro.dev/v6/auth"
)

// authClaims to be encoded in the JWT.
type authClaims struct {
	Type     string            `json:"type"`
	Scopes   []string          `json:"scopes"`
	Metadata map[string]string `json:"metadata"`

	jwt.RegisteredClaims
}

// JWT implementation of token provider.
type JWT struct {
	opts Options
}

// New returns an initialized basic provider.
func New(opts ...Option) Provider {
	return &JWT{
		opts: NewOptions(opts...),
	}
}

// Generate a new JWT.
func (j *JWT) Generate(acc *auth

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key