mirror of
https://github.com/vbatts/srvdav.git
synced 2025-07-26 12:00:28 +00:00
vendor: dep init
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
83a1e114b0
commit
6feae25207
945 changed files with 238318 additions and 0 deletions
35
vendor/github.com/abbot/go-http-auth/examples/digest.go
generated
vendored
Normal file
35
vendor/github.com/abbot/go-http-auth/examples/digest.go
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
// +build ignore
|
||||
|
||||
/*
|
||||
Example application using Digest auth
|
||||
|
||||
Build with:
|
||||
|
||||
go build digest.go
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
auth ".."
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func Secret(user, realm string) string {
|
||||
if user == "john" {
|
||||
// password is "hello"
|
||||
return "b98e16cbc3d01734b264adba7baa3bf9"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func handle(w http.ResponseWriter, r *auth.AuthenticatedRequest) {
|
||||
fmt.Fprintf(w, "<html><body><h1>Hello, %s!</h1></body></html>", r.Username)
|
||||
}
|
||||
|
||||
func main() {
|
||||
authenticator := auth.NewDigestAuthenticator("example.com", Secret)
|
||||
http.HandleFunc("/", authenticator.Wrap(handle))
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue