Documentation
¶
Overview ¶
Password tries to minimize the attack surface of a password by minimizing the time window of a password being valid. It uses derived keys from a hash/salted password value without using the original plain combination ever for authorization.
This enables the web use with basic auth by reducing the downsides that remain over TLS communication for automated tasks.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Password ¶
type Password struct {
// contains filtered or unexported fields
}
func Create ¶
New takes a password and an optional salt to return a hashed and optionally salted Password.
Example ¶
package main
import (
"fmt"
"log"
"catinello.eu/password"
)
var (
pass = []byte{100, 101, 102, 103, 104}
salt = []byte{0, 1, 2, 3, 4}
hash = "I)08P<rQ/Qfz434</2WVc4h%<n9n%.0o[o/vuPGF"
)
func main() {
p := password.Create(pass, salt)
if p.String() != hash {
log.Fatal("Create() failed to produce the expected hash value.")
}
fmt.Println(p)
}
Output: I)08P<rQ/Qfz434</2WVc4h%<n9n%.0o[o/vuPGF
func Import ¶
Import takes any byte slice value bigger than 32 bytes and an alternative derivation function.
Example ¶
package main
import (
"fmt"
"log"
"catinello.eu/password"
)
var (
hash = "I)08P<rQ/Qfz434</2WVc4h%<n9n%.0o[o/vuPGF"
p *password.Password
)
func main() {
b := p.Export()
n, err := password.Import(b, nil, nil)
if err != nil {
log.Fatal(err)
}
if n.String() != hash {
log.Fatal("Import() failed to produce the expected hash value.")
}
fmt.Println(n)
}
Output: I)08P<rQ/Qfz434</2WVc4h%<n9n%.0o[o/vuPGF
func (*Password) Derivation ¶
Derivation allows you to set your custom derivation function to compute a Token.
func (*Password) Export ¶
Export return the hash and salt of Password.
Example ¶
package main
import (
"fmt"
"log"
"catinello.eu/password"
)
var p *password.Password
func main() {
b := p.Export()
if len(b) != 32 {
log.Fatal("Export() is expected to export a 32 bytes slice.")
}
fmt.Println(len(b))
}
Output: 32
func (*Password) Now ¶
Now returns the Password objects Token derived from the given Compute function. If compute is nil, the default derivation Compute function is used which basically is an alias to default Token() returning an additional error.
func (*Password) Token ¶
Token returns the Password objects Tokens with the objects derivation Compute function. Errors will trigger a panic.
Example ¶
package main
import (
"bytes"
"fmt"
"log"
"catinello.eu/password"
)
var p *password.Password
func main() {
b := p.Export()
n, err := password.Import(b, nil, nil)
if err != nil {
log.Fatal(err)
}
if bytes.Compare(p.Token(), n.Token()) != 0 {
log.Fatal("Tokens failed to produce the same Token.")
}
fmt.Println(bytes.Compare(p.Token(), n.Token()))
}
Output: 0
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
password
module
|
|
|
https provides secure convenience functions for basic auth via secure (TLS) web based communication (client/server) based on the password library.
|
https provides secure convenience functions for basic auth via secure (TLS) web based communication (client/server) based on the password library. |