Documentation
¶
Index ¶
- Constants
- func CheckPassword(password []byte, salt []byte, hpassword []byte) (bool, error)
- func EncodeOAuth2Code(clientID, redirectURI, userID, sharedKey string) (code string, err error)
- func GenerateSalt() (salt []byte, err error)
- func HashPassword(password []byte, salt []byte) (hash []byte, err error)
- func Oauth2(next http.Handler, cnf web.Config) http.Handler
- func RandStringBytesMaskImprSrc(n int) string
- func TokenHandler(next http.Handler, cnf web.Config) http.Handler
- type Application
- type ApplicationManager
- type AuthController
- type OAuth2Controller
- type Response
- type User
- type UserManager
Constants ¶
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 ¶
CheckPassword vérifie si le mot de passe est correct
func EncodeOAuth2Code ¶
EncodeOAuth2Code generate an OAuth2 code
func HashPassword ¶
HashPassword hash un mot de passe
func RandStringBytesMaskImprSrc ¶
RandStringBytesMaskImprSrc Generate a random string
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 ¶
func (c *OAuth2Controller) Token(w http.ResponseWriter, r *http.Request)
Token returns a new access token
type Response ¶
Response Oauth2
func DecodeOAuth2Code ¶
DecodeOAuth2Code inverse of EncodeOAuth2Code
func NewResponse ¶
NewResponse returns a new OAuth2Response