diff --git a/.gitignore b/.gitignore index a1338d6..92027e5 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 .glide/ +vendor/ +*.lock diff --git a/Gopkg.toml b/Gopkg.toml new file mode 100644 index 0000000..35daa9b --- /dev/null +++ b/Gopkg.toml @@ -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" diff --git a/Makefile b/Makefile index 98e92d0..dfcae7f 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index b19a63f..624916b 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/app/web.go b/app/web.go index c8a2ae0..e756190 100644 --- a/app/web.go +++ b/app/web.go @@ -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)})