Documentation ¶
Overview ¶
Package auth determines and asserts client permissions to access and modify server resources.
Index ¶
- Variables
- func AuthenticateCaptcha(req Captcha) bool
- func BcryptCompare(password string, hash []byte) error
- func BcryptHash(password string, rounds int) ([]byte, error)
- func GetBannedLevels(board, ip string) (globally, locally bool)
- func GetIP(req *http.Request) string
- func GetNoscriptCaptcha(ip string) string
- func IsBanned(board, ip string) (banned bool)
- func IsBoard(board string) bool
- func IsNonMetaBoard(b string) bool
- func NewCaptchaID(w http.ResponseWriter, _ *http.Request)
- func RandomID(length int) (string, error)
- func ServeCaptcha(w http.ResponseWriter, r *http.Request)
- func SetBans(b ...Ban)
- type Ban
- type BanRecord
- type Captcha
- type SessionCreds
Constants ¶
This section is empty.
Variables ¶
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 ¶
AuthenticateCaptcha posts a request to the SolveMedia API to authenticate a captcha
func BcryptCompare ¶
BcryptCompare compares a bcrypt hash with a user-supplied string
func BcryptHash ¶
BcryptHash generates a bcrypt hash from the passed string
func GetBannedLevels ¶
GetBannedLevels is like IsBanned, but returns, if the IP is banned globally or only from the specific board.
func GetNoscriptCaptcha ¶
GetNoscriptCaptcha returns a captcha id by IP. Use only for clients with scripts disabled.
func IsNonMetaBoard ¶
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 ServeCaptcha ¶
func ServeCaptcha(w http.ResponseWriter, r *http.Request)
ServeCaptcha serves captcha images and audio
Types ¶
type Ban ¶
type Ban struct {
IP, Board string
}
Ban holdsan entry of an IP being banned from a board
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