auth

package
v4.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2017 License: AGPL-3.0, AGPL-3.0-or-later Imports: 12 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 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 IsBanned

func IsBanned(board, ip string) bool

IsBanned returns if the IP is banned on the target board

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

func SetBans

func SetBans(b ...Ban)

SetBans replaces the ban cache with the new set

Types

type Ban

type Ban struct {
	IP, Board string
}

Ban holdsan entry of an IP being banned from a board

type BanRecord

type BanRecord struct {
	Ban
	Reason, By string
	Expires    time.Time
}

BanRecord stores information about a specific ban

type SessionCreds

type SessionCreds struct {
	UserID, Session string
}

SessionCreds is embed in every request that needs logged in authentication

Jump to

Keyboard shortcuts

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