token

package
v0.0.0-...-e957825 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 2 Imported by: 2

Documentation

Overview

Package token implements an example of authorization token encoding/decoding that can be used in RPC headers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token struct {
	// Secret is used by the server to authenticate the user
	Secret string `json:"secret"`
	// Username is used by the server to assign roles in the metadata for authorization
	Username string `json:"username"`
}

Token is a mock authorization token sent by the client as part of the RPC headers, and used by the server for authorization against a predefined policy.

func (*Token) Decode

func (t *Token) Decode(s string) error

Decode updates the internals of Token using the passed in base64 encoded version of the JSON representation of token.

func (*Token) Encode

func (t *Token) Encode() (string, error)

Encode returns a base64 encoded version of the JSON representation of token.

Jump to

Keyboard shortcuts

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