auth

package
v0.0.0-...-ee3211a Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Protected = 2
View Source
var WriteProtected = 1

Functions

func ComparePassword

func ComparePassword(hash string, password string) bool

ComparePassword compares a hash and a password, returning true on match

Types

type Claims

type Claims struct {
	NotebookID string `json:"notebook_id"`
	jwt.StandardClaims
}

type Hasher

type Hasher struct {
	Cost int
}

func NewHasher

func NewHasher() *Hasher

func (*Hasher) HashPassword

func (h *Hasher) HashPassword(password string) (string, error)

HashPassword hashes a password

type Issuer

type Issuer struct {
	SigningKey []byte
}

func NewIssuer

func NewIssuer(key string) *Issuer

NewIssuer returns a new configured JWT issuer

func (*Issuer) Issue

func (issuer *Issuer) Issue(id string) (string, error)

Issue issues a new JWT

func (*Issuer) Validate

func (issuer *Issuer) Validate(token string) (*Claims, error)

Validate tries to validate a JWT, returning Claims or an error

func (*Issuer) ValidateNotebook

func (issuer *Issuer) ValidateNotebook(token string, notebookID string) bool

ValidateNotebook validates if a token grants authorized access to a notebook

type ProtectionLevel

type ProtectionLevel uint8

func (ProtectionLevel) Protected

func (p ProtectionLevel) Protected() bool

Protected checks if notebook is protected, meaning authentication is required to see and motify its contents.

func (ProtectionLevel) WriteProtected

func (p ProtectionLevel) WriteProtected() bool

WriteProtected checks if notebook is protected against writes, i.e. is read only by unauthenticated users.

Jump to

Keyboard shortcuts

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