util

package
v0.0.0-...-2187358 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ROOM_URL_SEGMENT = "/v/"

Variables

This section is empty.

Functions

func DefaultRoles

func DefaultRoles(r *http.Request, authorizer rbac.Authorizer, connUUID string, namespace connection.Namespace) ([]rbac.Role, error)

BindDefaultuserRoles computes the default roles to assign to a given connection request based on previously stored auth data as well as a connection's namespace state. The following rules will be followed (in the given order) when determining which roles to return:

  • If no other connections are bound to the given namespace, an "admin" role will be assigned and forced onto the connection - regardless of previously stored data on an existing auth cookie.
  • If auth information was previously stored in an auth cookie, and the computed role based on the namespace state is not "admin", the stored roles will be forced onto the connection.
  • If there is no previously stored information for the given namespace in an auth cookie, or the auth cookie does not exist, and there is at least one other connection assigned to the given namespace, a "user" role will be forced onto the connection.

func GenerateAuthCookie

func GenerateAuthCookie(cookieData *rbac.AuthCookieData) (*http.Cookie, error)

func GetCurrentDirectory

func GetCurrentDirectory() string

func NamespaceFromRequest

func NamespaceFromRequest(req *http.Request) (string, error)

GetRoomNameFromRequest receives a socket connection request and returns a fully-qualified room name from the request's referer information

func SerializeIntoResponse

func SerializeIntoResponse(codec api.ApiCodec, dest interface{}) error

serializeIntoResponse receives an api.ApiCodec and serializes it into a given structure pointer.

func SetAuthCookie

func SetAuthCookie(w http.ResponseWriter, r *http.Request, namespace connection.Namespace, roles []rbac.Role) (bool, error)

func UpdateClientUsername

func UpdateClientUsername(c *client.Client, username string, clientHandler client.SocketClientHandler) error

TODO: make this function concurrency-safe

func UpdatedAuthCookie

func UpdatedAuthCookie(r *http.Request, namespace connection.Namespace, roles []rbac.Role) (*http.Cookie, bool, error)

UpdatedAuthCookie receives a request, namespace, and set of roles and returns an existing auth cookie with its role data updated, or a new auth cookie with the given role data

Types

This section is empty.

Jump to

Keyboard shortcuts

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