auth

package
v1.7.0-dev-20190926 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: Apache-2.0 Imports: 12 Imported by: 35

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 ClientInterceptor

func ClientInterceptor(token Token) grpc.UnaryClientInterceptor

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

func ServerInterceptor

func ServerInterceptor(token Token) grpc.UnaryServerInterceptor

ServerInterceptor 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 added in v0.9.6

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