auth

package
v0.0.0-...-7bfb722 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearSession

func ClearSession(r *safehttp.IncomingRequest)

ClearSession clears the session.

Implementation details: to interact with the interceptor, passes data through the IncomingRequest's context.

func CreateSession

func CreateSession(r *safehttp.IncomingRequest, user string)

CreateSession creates a session.

Implementation details: to interact with the interceptor, passes data through the IncomingRequest's context.

func User

User retrieves the user.

Types

type Interceptor

type Interceptor struct {
	DB *storage.DB
}

Interceptor is an auth (access control) interceptor.

It showcases how safehttp.Interceptor could be implement to provide custom security features. See https://pkg.go.dev/github.com/google/go-safeweb/safehttp#hdr-Interceptors.

In order to interact with the interceptor, use functions from this package. E.g. to clear a user session call ClearSession.

func (Interceptor) Before

Before runs before the request is passed to the handler.

Implementation details: this interceptor uses IncomingRequest's context to store user information that's read from a cookie.

func (Interceptor) Commit

Commit runs after the handler commited to a response.

Implementation details: the interceptor reads IncomingRequest's context to retrieve information about the user and to do what the handler asked it to (through ClearSession or CreateSession).

func (Interceptor) Match

type Skip

type Skip struct{}

Skip allows to mark an endpoint to skip auth checks.

Its uses would normally be gated by a security review. You can use the https://github.com/google/go-safeweb/blob/master/cmd/bancheck tool to enforce this.

Jump to

Keyboard shortcuts

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