auth

package
v3.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2016 License: AGPL-3.0, AGPL-3.0-or-later Imports: 13 Imported by: 0

Documentation

Overview

Package auth determines and asserts client permissions to access and modify server resources.

Index

Constants

This section is empty.

Variables

View Source
var (
	// IsReverseProxied specifies, if the server is deployed behind a reverse
	// proxy.
	IsReverseProxied bool

	// ReverseProxyIP specifies the IP of a non-localhost reverse proxy. Used
	// for filtering in XFF IP determination.
	ReverseProxyIP string
)

Functions

func AuthenticateCaptcha

func AuthenticateCaptcha(captcha common.Captcha, ip string) bool

AuthenticateCaptcha posts a request to the SolveMedia API to authenticate a captcha

func BcryptCompare

func BcryptCompare(password string, hash []byte) error

BcryptCompare compares a bcrypt hash with a user-supplied string

func BcryptHash

func BcryptHash(password string, rounds int) ([]byte, error)

BcryptHash generates a bcrypt hash from the passed string

func GetIP

func GetIP(req *http.Request) string

GetIP extracts the IP of a request, honouring reverse proxies, if set

func IsBoard

func IsBoard(board string) bool

IsBoard confirms the string is a valid board

func IsNonMetaBoard

func IsNonMetaBoard(b string) bool

IsNonMetaBoard returns whether a valid board is a classic board and not some other path that emulates a board

func RandomID

func RandomID(length int) (string, error)

RandomID generates a randomID of base64 characters of desired byte length

Types

type Ident

type Ident struct {
	UserID string
	IP     string
}

Ident is used to verify a client's access and write permissions. Contains its IP and logged in user data, if any.

func LookUpIdent

func LookUpIdent(req *http.Request) Ident

LookUpIdent determine access rights of an IP

type Session

type Session struct {
	Token   string    `gorethink:"token"`
	Expires time.Time `gorethink:"expires"`
}

Session contains the token and expiry time of a single authenticated login session

type User

type User struct {
	ID       string    `gorethink:"id"`
	Password []byte    `gorethink:"password"`
	Sessions []Session `gorethink:"sessions"`
}

User contains ID, password hash and board-related data of a registered user account

Jump to

Keyboard shortcuts

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