auth

package
v3.3.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package auth provides simple token based, stream authorization functions.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrInvalidToken is returned by Check when the auth-token was not as
	// expected.
	ErrInvalidToken = fmt.Errorf("Invalid auth-token code")

	// NoAuth is the token used for authenticationless connections.
	NoAuth = Token("")
)

Functions

func StreamClientInterceptor

func StreamClientInterceptor(token Token) grpc.StreamClientInterceptor

StreamClientInterceptor returns a grpc.StreamClientInterceptor that adds the given auth token to outgoing RPC calls.

func StreamServerInterceptor

func StreamServerInterceptor(token Token) grpc.StreamServerInterceptor

StreamServerInterceptor returns a grpc.StreamServerInterceptor that checks incoming RPC calls for the given auth token.

func UnaryClientInterceptor

func UnaryClientInterceptor(token Token) grpc.UnaryClientInterceptor

UnaryClientInterceptor returns a grpc.UnaryClientInterceptor that adds the given auth token to outgoing RPC calls.

func UnaryServerInterceptor

func UnaryServerInterceptor(token Token) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a grpc.UnaryServerInterceptor that checks incoming RPC calls for the given auth token.

func Write

func Write(s io.Writer, token Token) error

Write writes the authorization token to s.

Types

type Token

type Token string

Token is a secret password that must be sent on connection.

func GenToken

func GenToken() Token

GenToken returns a 8 character random token.

func GenTokenFile

func GenTokenFile() (path string, token Token)

GenTokenFile creates and returns the path to a temporary file containing a token generated by GenToken() with read & write permissions of the current processes.

Jump to

Keyboard shortcuts

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