Created
August 16, 2013 14:27
-
-
Save kachayev/6250394 to your computer and use it in GitHub Desktop.
Basic Authentication for http.FileServer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
What is the encryption algorithm?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can I generate my own hash and perform comparison between original and requested pass phrase ?