auth

package
v1.4.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopeUser       = "b3scale"
	ScopeAdmin      = "b3scale:admin"
	ScopeNode       = "b3scale:node"
	ScopeRecordings = "b3scale:recordings"
	ScopeCallback   = "b3scale:callback"
)

Scopes

Variables

This section is empty.

Functions

func EncodeResource

func EncodeResource(hint, id string) string

EncodeResource associates an ID string with a type hint. Resources can for example be `recordings`, `frontend`, etc...

func ErrScopeRequired

func ErrScopeRequired(scopes ...string) *echo.HTTPError

ErrScopeRequired will be returned when a scope is missing from the response.

func GenerateNonce

func GenerateNonce(n int) string

GenerateNonce will create a random string of length n

func GenerateRef

func GenerateRef(n int) string

GenerateRef will create a most likely unique combination of words.

func MustDecodeResource

func MustDecodeResource(resource string) (string, string)

MustDecodeResource decodes splits a resource token into a type hint and an ID string. If the token is invalid, this function will panic.

func NewJWTAuthMiddleware

func NewJWTAuthMiddleware(secret string) echo.MiddlewareFunc

NewJWTAuthMiddleware creates a new instance of the echojwt middleware. Parameters like shared secrets, public keys, etc.. are retrieved from the environment.

func ParseUnverifiedRawToken added in v1.1.1

func ParseUnverifiedRawToken(data string) (jwt.MapClaims, error)

ParseUnverifiedRawToken decodes a token without validating it.

func SignRawToken added in v1.1.1

func SignRawToken(claims jwt.MapClaims, secret string) (string, error)

SignRawToken creates a token with map claims signed with a secret using the HS256 signing method, because the BBB API specifies this:

https://docs.bigbluebutton.org/development/api/#recording-ready-callback-url

Types

type Claims

type Claims struct {
	Scope string `json:"scope"`
	jwt.RegisteredClaims
}

Claims extends the JWT standard claims with a well-known `scope` claim.

func NewClaims

func NewClaims(sub string) *Claims

NewClaims creates a new set of claims for use with the API. This includes an ID and the subject.

The subject can be any string, however it will be used as an identifier for the 'user' making the request.

func ParseAPIToken

func ParseAPIToken(data, secret string) (*Claims, error)

ParseAPIToken validates and parses a JWT token.

func (*Claims) Audience added in v1.1.1

func (c *Claims) Audience() string

Audience returns the audience of the claims

func (*Claims) HasScope added in v1.1.1

func (c *Claims) HasScope(scope string) bool

HasScope checks if the token has a scope

func (*Claims) Scopes

func (c *Claims) Scopes() []string

Scopes returns the list of scopes.

func (*Claims) Sign

func (c *Claims) Sign(secret string) (string, error)

Sign will create a new JWT from the claims.

func (*Claims) Subject added in v1.1.1

func (c *Claims) Subject() string

Subject returns the subject of the claims

func (*Claims) WithAudience

func (c *Claims) WithAudience(aud string) *Claims

WithAudience adds an audience to the claims.

func (*Claims) WithLifetime

func (c *Claims) WithLifetime(ttl time.Duration) *Claims

WithLifetime adds a lifetime to the claims.

func (*Claims) WithScopes

func (c *Claims) WithScopes(scopes ...string) *Claims

WithScopes adds a list of scopes to the claims.

func (*Claims) WithScopesCSV

func (c *Claims) WithScopesCSV(scopes string) *Claims

WithScopesCSV adds a list of scopes to the claims, separated by a delimiter.

type Scopes

type Scopes []string

Scopes is a list of scopes

Jump to

Keyboard shortcuts

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