security

package
v0.0.0-...-2e7332a Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2019 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KEYLENGTH = 32
	N         = 16384
	R         = 8
	P         = 1
	S         = 32
)

Constantes nécessaires à l'encryption du mot de passe

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(password []byte, salt []byte, hpassword []byte) (bool, error)

CheckPassword vérifie si le mot de passe est correct

func EncodeOAuth2Code

func EncodeOAuth2Code(clientID, redirectURI, userID, sharedKey string) (code string, err error)

EncodeOAuth2Code generate an OAuth2 code

func GenerateSalt

func GenerateSalt() (salt []byte, err error)

GenerateSalt génère le salage

func HashPassword

func HashPassword(password []byte, salt []byte) (hash []byte, err error)

HashPassword hash un mot de passe

func Oauth2

func Oauth2(next http.Handler, cnf web.Config) http.Handler

Oauth2 manage authorizations

func RandStringBytesMaskImprSrc

func RandStringBytesMaskImprSrc(n int) string

RandStringBytesMaskImprSrc Generate a random string

func TokenHandler

func TokenHandler(next http.Handler, cnf web.Config) http.Handler

TokenHandler manage authorizations

Types

type Application

type Application struct {
	ClientID    string
	Secret      string
	Name        string
	URL         string
	Description string
	Callback    string
	User        User
}

Application to OAuth2

type ApplicationManager

type ApplicationManager interface {
	GetByClientID(clientID string) (application Application, err error)
}

ApplicationManager to manage Application

type AuthController

type AuthController struct {
	UserManager UserManager
	// contains filtered or unexported fields
}

AuthController manages Authentication in Server.

func NewAuthController

func NewAuthController(um UserManager, cnf web.Config) *AuthController

NewAuthController constructs new AuthController

func (*AuthController) Authenticate

func (c *AuthController) Authenticate(w http.ResponseWriter, r *http.Request)

Authenticate controls authorizations

type OAuth2Controller

type OAuth2Controller struct {
	ApplicationManager ApplicationManager
	// contains filtered or unexported fields
}

OAuth2Controller manages Authentication in Server.

func NewOAuth2Controller

func NewOAuth2Controller(am ApplicationManager, cnf web.Config) *OAuth2Controller

NewOAuth2Controller constructs new AuthController

func (*OAuth2Controller) Authorize

func (c *OAuth2Controller) Authorize(w http.ResponseWriter, r *http.Request)

Authorize user

func (*OAuth2Controller) Refresh

func (c *OAuth2Controller) Refresh(w http.ResponseWriter, r *http.Request)

Refresh returns a new access token

func (*OAuth2Controller) Token

Token returns a new access token

type Response

type Response struct {
	ClientID    string
	RedirectURI string
	UserID      string
	Exp         string
	Code        string
}

Response Oauth2

func DecodeOAuth2Code

func DecodeOAuth2Code(code, sharedKey string) (response Response, err error)

DecodeOAuth2Code inverse of EncodeOAuth2Code

func NewResponse

func NewResponse(clientID, redirectURI, userID, exp, code string) Response

NewResponse returns a new OAuth2Response

type User

type User struct {
	Username string
	Password string
	Salt     string
	Email    string
}

User in Auhtentication

type UserManager

type UserManager interface {
	//Get a user
	Get(username string, password string) (user User, err error)
}

UserManager to manage user.

Jump to

Keyboard shortcuts

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