security

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: BSD-2-Clause Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package security holds the checks that decide whether a connection from outside is allowed in.

Index

Constants

View Source
const AllowedOriginsEnv = "JARGO_ALLOWED_ORIGINS"

AllowedOriginsEnv is the environment variable naming the origins a browser client may open a socket from, as a comma-separated list. It is the default for every endpoint that takes an origin list, so a deployment can set the policy once instead of threading it through each one.

Variables

This section is empty.

Functions

func DefaultAllowedOrigins added in v0.2.0

func DefaultAllowedOrigins() []string

DefaultAllowedOrigins returns the origins AllowedOriginsEnv names, or none when it is unset or empty, which allows every origin. Blank entries are dropped, so a trailing comma does not turn into an origin nothing matches.

func IsOriginAllowed

func IsOriginAllowed(origin string, allowed []string) bool

IsOriginAllowed reports whether origin, the value of a request's Origin header, is permitted by allowed.

An empty allowed list permits every origin, including a request that carries no Origin header at all: that is the default, and it is what a telephony provider streaming a call needs, since it is not a browser and sends no origin. A non-empty list permits only the origins it names, matched whole and without regard to case, and rejects a request whose origin is missing.

It is the guard against a page on another site opening a WebSocket to this one on a visitor's behalf: the browser sends the page's origin, and a server that never looks at it accepts the connection as readily as its own client's.

Types

This section is empty.

Jump to

Keyboard shortcuts

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