auth

package
v4.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2017 License: AGPL-3.0, AGPL-3.0-or-later Imports: 10 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(req Captcha) 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 GetBannedLevels

func GetBannedLevels(board, ip string) (globally, locally bool)

GetBannedLevels is like IsBanned, but returns, if the IP is banned globally or only from the specific board.

func GetIP

func GetIP(req *http.Request) string

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

func GetNoscriptCaptcha

func GetNoscriptCaptcha(ip string) string

GetNoscriptCaptcha returns a captcha id by IP. Use only for clients with scripts disabled.

func IsBanned

func IsBanned(board, ip string) (banned 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 NewCaptchaID

func NewCaptchaID(w http.ResponseWriter, _ *http.Request)

NewCaptchaID creates a new captcha and write its ID to the client

func RandomID

func RandomID(length int) (string, error)

RandomID generates a randomID of base64 characters of desired byte length

func ServeCaptcha

func ServeCaptcha(w http.ResponseWriter, r *http.Request)

ServeCaptcha serves captcha images and audio

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 Captcha

type Captcha struct {
	CaptchaID, Solution string
}

Captcha contains the ID and solution of a captcha-protected request

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