Refine documentation and code doc

This commit is contained in:
Nick Penkov
2018-01-27 20:19:44 +01:00
parent 173d059c82
commit 6216de78e4
5 changed files with 63 additions and 2 deletions

2
.gitignore vendored
View File

@ -12,3 +12,5 @@
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/
vendor/
*.lock

26
Gopkg.toml Normal file
View File

@ -0,0 +1,26 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
[[constraint]]
name = "gopkg.in/ldap.v2"
version = "2.5.1"

View File

@ -3,8 +3,11 @@ VER=1.0
.PHONY: all build push
all: build docker push clean
all: init build docker push clean
init:
dep ensure
build:
GOOS=linux go build -o ldap-pass-webui main.go

View File

@ -4,7 +4,29 @@ WebUI Client capable of connecting to backend LDAP server and changing the users
![Screenshot](screenshots/index.png)
## Running in docker container
The configuration is made with environment variables:
|Env variable|Default value|Description|
|------------|-------------|-----------|
|LPW_TITLE|Change your global password for example.org|Title that will appear on the page|
|LPW_HOST||LDAP Host to connect to|
|LPW_PORT|636|LDAP Port (389|636 are default LDAP/LDAPS)|
|LPW_ENCRYPTED|true|Use enrypted communication|
|LPW_START_TLS|false|Start TLS communication|
|LPW_SSL_SKIP_VERIFY|true|Skip TLS CA verification|
|LPW_USER_DN|uid=%s,ou=people,dc=example,dc=org|Filter expression to search the user for Binding|
|LPW_USER_BASE|ou=people,dc=example,dc=org|Base to use when doing the binding|
## Running
```sh
dep ensure
LPW_HOST=ldap_host_ip go run main.go
```
Browse [http://localhost:8080/](http://localhost:8080/)
### Running in docker container
```sh
docker run -d -p 8080:8080 --name ldap-passwd-webui \
@ -21,6 +43,11 @@ docker run -d -p 8080:8080 --name ldap-passwd-webui \
## Building and tagging
Get [Godep](https://github.com/golang/dep)
```sh
go get -u github.com/golang/dep/cmd/dep
```
```sh
make
```

View File

@ -19,14 +19,17 @@ type route struct {
handler http.Handler
}
// RegexpHandler is used for http handler to bind using regular expressions
type RegexpHandler struct {
routes []*route
}
// Handler binds http handler on RegexpHandler
func (h *RegexpHandler) Handler(pattern *regexp.Regexp, verb string, handler http.Handler) {
h.routes = append(h.routes, &route{pattern, verb, handler})
}
// HandleFunc binds http handler function on RegexpHandler
func (h *RegexpHandler) HandleFunc(r string, v string, handler func(http.ResponseWriter, *http.Request)) {
re := regexp.MustCompile(r)
h.routes = append(h.routes, &route{re, v, http.HandlerFunc(handler)})