guard

package
v0.6.114 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package guard protects the platform port with the installation's internal secret: the console relay presents it, the SDK checks it. Health stays open for Consul checks and probes. An empty secret disables the guard. While the secret rotates the previous one is accepted too.

Index

Constants

View Source
const (
	Header     = "bp-internal-secret"
	HTTPHeader = "Bp-Internal-Secret"
	// SessionHeader names the console session of a call the console relays:
	// the console drops the browser's bp-* keys and sets it itself.
	SessionHeader = "bp-console-session"
)

Header carries the secret: gRPC metadata key and, canonicalized, HTTPHeader.

Variables

This section is empty.

Functions

func Session added in v0.6.23

func Session(ctx context.Context) (uuid.UUID, bool)

Session is the console session of a call that passed the guard.

func WithSession added in v0.6.25

func WithSession(ctx context.Context, session uuid.UUID) context.Context

WithSession is ctx carrying session as the console session of a call that passed the guard (backplanetest.Operator).

Types

type Guard

type Guard struct {
	// contains filtered or unexported fields
}

Guard checks the secret.

func New

func New(secret string, previous ...string) Guard

New creates a guard accepting secret and, during a rotation, the previous ones; an empty secret allows everything whatever the previous ones are.

func (Guard) Authorize

func (g Guard) Authorize(ctx context.Context, method string) error

Authorize checks the secret in incoming gRPC metadata; health is exempt. The error is a gRPC status and is returned as is.

func (Guard) HTTP

func (g Guard) HTTP(next http.Handler) http.Handler

HTTP wraps a handler.

func (Guard) ServerOptions

func (g Guard) ServerOptions() []grpc.ServerOption

ServerOptions installs the guard on a gRPC server.

Jump to

Keyboard shortcuts

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