auth

package
v0.0.0-...-5ce4b29 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const AnonymousUserID = 0

AnonymousUserID is the ID only an unauthenticated user can have.

View Source
const CurrentUserKey = ContextKey("currentUser")

CurrentUserKey is the Context key used for the current user.

Variables

View Source
var AnonymousUser = User{
	ID:   AnonymousUserID,
	Name: "Anonymous",
}

AnonymousUser represents an unauthenticated user

Functions

func NewContextWithCurrentUser

func NewContextWithCurrentUser(r *http.Request) context.Context

NewContextWithCurrentUser parses the request to create a new context containing the current user. The current user may be the anonymous user if there is nothing in the request to make an identification.

Types

type ContextKey

type ContextKey string

ContextKey is used as keys for Contexts

type User

type User struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

User represents the user making the request

Jump to

Keyboard shortcuts

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