Skip to content

Instantly share code, notes, and snippets.

@kachayev
Created August 16, 2013 14:27
Show Gist options
  • Save kachayev/6250394 to your computer and use it in GitHub Desktop.
Save kachayev/6250394 to your computer and use it in GitHub Desktop.
Basic Authentication for http.FileServer
package main
import (
"fmt"
"net/http"
auth "github.com/abbot/go-http-auth"
)
func Secret(user, realm string) string {
if user == "john" {
// password is "hello"
return "$1$dlPL2MqE$oQmn16q49SqdmhenQuNgs1"
}
return ""
}
func main() {
fmt.Println("-----> Starting HTTP server...")
authenticator := auth.NewBasicAuthenticator("secret.com", Secret)
http.HandleFunc("/", authenticator.Wrap(func(res http.ResponseWriter, req *auth.AuthenticatedRequest) {
http.FileServer(http.Dir(".")).ServeHTTP(res, &req.Request)
}))
http.ListenAndServe(":5042", nil)
}
@c0d3sling3r
Copy link

c0d3sling3r commented Aug 12, 2017

How can I generate my own hash and perform comparison between original and requested pass phrase ?

@andrew-eldridge
Copy link

What is the encryption algorithm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment