Documentation
¶
Overview ¶
Package auth is a authentication helper that supports multiple types of applications.
Index ¶
- Constants
- Variables
- func CheckHS256(input []byte, mac []byte, key []byte) error
- func CheckHS512(input []byte, mac []byte, key []byte) error
- func FromBase64(input string) ([]byte, error)
- func FromBase64Std(input string) ([]byte, error)
- func FromHex(input string) ([]byte, error)
- func HS256(data []byte, key []byte) ([]byte, error)
- func HS512(data []byte, key []byte) ([]byte, error)
- func SHA256(data []byte) ([]byte, error)
- func SHA512(data []byte) ([]byte, error)
- func ToBase64(data []byte) (string, error)
- func ToBase64Std(data []byte) (string, error)
- func ToHex(data []byte) (string, error)
- type Auth
- type PasswordHash
Constants ¶
const ( // BcryptDefaultCost is the Bcrypt Default Cost where the performace is optimal BcryptDefaultCost int = bcrypt.DefaultCost // BcryptMaxCost is the Bcrypt Maximum Cost with Longest Time BcryptMaxCost int = bcrypt.MaxCost // BcryptMinCost is the Bcrypt Minimum Cost with Shortest time BcryptMinCost int = bcrypt.MinCost )
const MethodPasswordHashBcrypt = "Password Hash using bcrypt"
MethodPasswordHashBcrypt defines password hash generation using bcrypt
const MethodPasswordHashPbkdf2S256 = "Password Hash using pbkdf2 and HMAC-SHA256"
MethodPasswordHashPbkdf2S256 defines password hash generation using pbkdf2 with HMAC-SHA256
Variables ¶
var ErrNotImplemented = fmt.Errorf("error functionality not implemented yet")
ErrNotImplemented occurs when an Un-implemented feature is called on
var ErrNotInitialized = fmt.Errorf("error this construct is not initialized")
ErrNotInitialized occurs when an Authentication process or function tries to access an un-initialized data parameter or construct.
var ErrParameter = fmt.Errorf("error in supplied parameters")
ErrParameter occurs when there are issues with the supplied parameter in any function.
Functions ¶
func CheckHS256 ¶ added in v0.0.4
CheckHS256 verifies the given MAC with supplied input
func CheckHS512 ¶ added in v0.0.4
CheckHS512 verifies the given MAC with supplied input
func FromBase64 ¶ added in v0.0.4
FromBase64 converts a URL-Base64 encoded string back to a bytes array
func FromBase64Std ¶ added in v0.0.4
FromBase64Std converts a Standard-Base64 encoded string back to a bytes array
func HS256 ¶ added in v0.0.4
HS256 performs the HMAC-SHA256 operation on input data using the supplied key
func HS512 ¶ added in v0.0.4
HS512 performs the HMAC-SHA512 operation on input data using the supplied key
func ToBase64Std ¶ added in v0.0.4
ToBase64Std converts a bytes array into a Standard-Base64 Encoded string
Types ¶
type Auth ¶
type Auth interface {
// Create function generates the Authentication Entity by processing
// incoming data and the specific 'bias'.
Create(data []byte, bias interface{}) ([]byte, error)
// Verify function checks the Authentication Entity by processing
// it with the optional incoming 'bias'. It also recovers the original
// 'data' and 'bias' used to create the Authentication Entity.
Verify(value []byte, bias interface{}) ([]byte, interface{}, error)
// Set function configures the Authentication Entity creation and
// verification process. It also accepts the static "Key" that needs
// to be employed while processing the Authentication Entity.
Set(method string, key interface{}) error
}
Auth is the generic interface that would be implemented by the various authentication algorithms and classifications.
The term "Authentication Entity" refers to a token, pass, or a Unique piece of information that provides Identity, and Authorization status of the bearer.
func NewPasswordHash ¶ added in v0.0.2
NewPasswordHash Configures the respective password Hashing algorithm and returns the instance which implements the Auth Interface
type PasswordHash ¶ added in v0.0.2
type PasswordHash struct {
// contains filtered or unexported fields
}
PasswordHash is used to generated cryptographically secure digest from the supplied password and also verify the digest.