• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..19-Feb-2022-

.gitignoreH A D19-Feb-202230 65

.travis.ymlH A D19-Feb-2022217 2116

LICENSEH A D19-Feb-20229.9 KiB179150

MakefileH A D19-Feb-2022159 1310

README.mdH A D19-Feb-20222.2 KiB7253

auth.goH A D19-Feb-20223.5 KiB11146

basic.goH A D19-Feb-20225.2 KiB162104

digest.goH A D19-Feb-20229.7 KiB317212

go.modH A D19-Feb-2022110 63

go.sumH A D19-Feb-2022724 87

md5crypt.goH A D19-Feb-20221.3 KiB7457

misc.goH A D19-Feb-20223.6 KiB142107

test.htdigestH A D19-Feb-202250 21

test.htpasswdH A D19-Feb-2022195 54

users.goH A D19-Feb-20223.6 KiB152111

README.md

1HTTP Authentication implementation in Go
2========================================
3
4This is an implementation of HTTP Basic and HTTP Digest authentication
5in Go language. It is designed as a simple wrapper for
6http.RequestHandler functions.
7
8Features
9--------
10
11 * Supports HTTP Basic and HTTP Digest authentication.
12 * Supports htpasswd and htdigest formatted files.
13 * Automatic reloading of password files.
14 * Pluggable interface for user/password storage.
15 * Supports MD5, SHA1 and BCrypt for Basic authentication password storage.
16 * Configurable Digest nonce cache size with expiration.
17 * Wrapper for legacy http handlers (http.HandlerFunc interface)
18
19Example usage
20-------------
21
22This is a complete working example for Basic auth:
23
24    package main
25
26    import (
27            "fmt"
28            "net/http"
29
30            auth "github.com/abbot/go-http-auth"
31    )
32
33    func Secret(user, realm string) string {
34            if user == "john" {
35                    // password is "hello"
36                    return "$1$dlPL2MqE$oQmn16q49SqdmhenQuNgs1"
37            }
38            return ""
39    }
40
41    func handle(w http.ResponseWriter, r *auth.AuthenticatedRequest) {
42            fmt.Fprintf(w, "<html><body><h1>Hello, %s!</h1></body></html>", r.Username)
43    }
44
45    func main() {
46            authenticator := auth.NewBasicAuthenticator("example.com", Secret)
47            http.HandleFunc("/", authenticator.Wrap(handle))
48            http.ListenAndServe(":8080", nil)
49    }
50
51See more examples in the "examples" directory.
52
53Legal
54-----
55
56This module is developed under Apache 2.0 license, and can be used for
57open and proprietary projects.
58
59Copyright 2012-2013 Lev Shamardin
60
61Licensed under the Apache License, Version 2.0 (the "License"); you
62may not use this file or any other part of this project except in
63compliance with the License. You may obtain a copy of the License at
64
65http://www.apache.org/licenses/LICENSE-2.0
66
67Unless required by applicable law or agreed to in writing, software
68distributed under the License is distributed on an "AS IS" BASIS,
69WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
70implied. See the License for the specific language governing
71permissions and limitations under the License.
72