mirror of
https://github.com/nabbar/golib.git
synced 2025-12-24 11:51:02 +08:00
Update + add modules
This commit is contained in:
10
.gitignore
vendored
10
.gitignore
vendored
@@ -12,4 +12,12 @@
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
vendor/
|
||||
vendor*/
|
||||
*.lock
|
||||
|
||||
# Jetbrain IDE files
|
||||
.idea/
|
||||
.idea/*
|
||||
.idea/**/*
|
||||
|
||||
|
||||
19
README.md
19
README.md
@@ -1,11 +1,14 @@
|
||||
GoDoc | Travis | Snyk
|
||||
:-: | :-: | :-:
|
||||
[](https://godoc.org/github.com/nabbar/gopkg-njs-logger) | [](https://travis-ci.com/nabbar/gopkg-njs-logger) | [](https://snyk.io/test/github/nabbar/gopkg-njs-logger)
|
||||
# golib : custom lib for go
|
||||
|
||||
# gopkg-njs-logger
|
||||
## using in source code
|
||||
first get the source dependancies
|
||||
```shell script
|
||||
go get -u github.com/nabbar/golib/...
|
||||
```
|
||||
|
||||
This lib is a more an helper than a lib.
|
||||
second, import the needed lib in your code
|
||||
```go
|
||||
import "github.com/nabbar/golib/njs-version"
|
||||
```
|
||||
|
||||
This lib is use to simplify integration and common use of the lib logrus
|
||||
|
||||
... in construction
|
||||
more information in each lib
|
||||
|
||||
32
go.mod
Normal file
32
go.mod
Normal file
@@ -0,0 +1,32 @@
|
||||
module github.com/nabbar/golib
|
||||
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/fatih/color v1.8.0
|
||||
github.com/gin-gonic/gin v1.5.0
|
||||
github.com/go-playground/universal-translator v0.17.0 // indirect
|
||||
github.com/gobuffalo/envy v1.8.1 // indirect
|
||||
github.com/gobuffalo/packr v1.30.1
|
||||
github.com/hashicorp/go-version v1.2.0
|
||||
github.com/json-iterator/go v1.1.9 // indirect
|
||||
github.com/leodido/go-urn v1.2.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.4 // indirect
|
||||
github.com/mattn/go-isatty v0.0.11 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.1 // indirect
|
||||
github.com/onsi/ginkgo v1.11.0 // indirect
|
||||
github.com/onsi/gomega v1.8.1 // indirect
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/rogpeppe/go-internal v1.5.1 // indirect
|
||||
github.com/sirupsen/logrus v1.4.2
|
||||
github.com/vjeantet/ldapserver v0.0.0-20170919170217-479fece7c5f1 // indirect
|
||||
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect
|
||||
golang.org/x/sys v0.0.0-20200103143344-a1369afcdac7 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
|
||||
gopkg.in/go-playground/validator.v9 v9.31.0 // indirect
|
||||
gopkg.in/ldap.v2 v2.5.1 // indirect
|
||||
gopkg.in/ldap.v3 v3.1.0
|
||||
gopkg.in/yaml.v2 v2.2.7 // indirect
|
||||
)
|
||||
176
go.sum
Normal file
176
go.sum
Normal file
@@ -0,0 +1,176 @@
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fatih/color v1.8.0 h1:5bzFgL+oy7JITMTxUPJ00n7VxmYd/PdMp5mHFX40/RY=
|
||||
github.com/fatih/color v1.8.0/go.mod h1:3l45GVGkyrnYNl9HoIjnp2NnNWvh6hLAqD8yTfGjnw8=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.5.0 h1:fi+bqFAx/oLK54somfCtEZs9HeH1LHVoEPUgARpTqyc=
|
||||
github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do=
|
||||
github.com/go-playground/locales v0.12.1 h1:2FITxuFt/xuCNP1Acdhv62OzaCiviiE4kotfhkmOqEc=
|
||||
github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM=
|
||||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||
github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM=
|
||||
github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY=
|
||||
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/gobuffalo/envy v1.7.0 h1:GlXgaiBkmrYMHco6t4j7SacKO4XUjvh5pwXh0f4uxXU=
|
||||
github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
|
||||
github.com/gobuffalo/envy v1.8.1 h1:RUr68liRvs0TS1D5qdW3mQv2SjAsu1QWMCx1tG4kDjs=
|
||||
github.com/gobuffalo/envy v1.8.1/go.mod h1:FurDp9+EDPE4aIUS3ZLyD+7/9fpx7YRt/ukY6jIHf0w=
|
||||
github.com/gobuffalo/logger v1.0.0/go.mod h1:2zbswyIUa45I+c+FLXuWl9zSWEiVuthsk8ze5s8JvPs=
|
||||
github.com/gobuffalo/packd v0.3.0 h1:eMwymTkA1uXsqxS0Tpoop3Lc0u3kTfiMBE6nKtQU4g4=
|
||||
github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b36chA3Q=
|
||||
github.com/gobuffalo/packr v1.30.1 h1:hu1fuVR3fXEZR7rXNW3h8rqSML8EVAf6KNm0NKO/wKg=
|
||||
github.com/gobuffalo/packr v1.30.1/go.mod h1:ljMyFO2EcrnzsHsN99cvbq055Y9OhRrIaviy289eRuk=
|
||||
github.com/gobuffalo/packr/v2 v2.5.1/go.mod h1:8f9c96ITobJlPzI44jj+4tHnEKNt0xXWSVlXRN9X1Iw=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E=
|
||||
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo=
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/karrick/godirwalk v1.10.12/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8=
|
||||
github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
|
||||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg=
|
||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
||||
github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
|
||||
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw=
|
||||
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.8.1 h1:C5Dqfs/LeauYDX0jJXIe2SWmwCbGzx9yF8C8xy3Lh34=
|
||||
github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.3.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.5.1 h1:asQ0uD7BN9RU5Im41SEEZTwCi/zAXdMOLS3npYaos2g=
|
||||
github.com/rogpeppe/go-internal v1.5.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/vjeantet/ldapserver v0.0.0-20170919170217-479fece7c5f1 h1:VWE8ZC9ER1YIfx0V0QgZGdG4UB/nGeaSmKxesfVuheo=
|
||||
github.com/vjeantet/ldapserver v0.0.0-20170919170217-479fece7c5f1/go.mod h1:+KHPMCVmFBVXK3UAUom0AgP/IeOXH5C3ieEwA+JU3WE=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 h1:sKJQZMuxjOAR/Uo2LBfU90onWEf1dF4C+0hPJCc9Mpc=
|
||||
golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180202135801-37707fdb30a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200103143344-a1369afcdac7 h1:/W9OPMnnpmFXHYkcp2rQsbFUbRlRzfECQjmAFiOyHE8=
|
||||
golang.org/x/sys v0.0.0-20200103143344-a1369afcdac7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d h1:TxyelI5cVkbREznMhfzycHdkp5cLA7DpE+GKjSslYhM=
|
||||
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
|
||||
gopkg.in/go-playground/validator.v9 v9.29.1 h1:SvGtYmN60a5CVKTOzMSyfzWDeZRxRuGvRQyEAKbw1xc=
|
||||
gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
|
||||
gopkg.in/go-playground/validator.v9 v9.31.0 h1:bmXmP2RSNtFES+bn4uYuHT7iJFJv7Vj+an+ZQdDaD1M=
|
||||
gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
|
||||
gopkg.in/ldap.v2 v2.5.1 h1:wiu0okdNfjlBzg6UWvd1Hn8Y+Ux17/u/4nlk4CQr6tU=
|
||||
gopkg.in/ldap.v2 v2.5.1/go.mod h1:oI0cpe/D7HRtBQl8aTg+ZmzFUAvu4lsv3eLXMLGFxWk=
|
||||
gopkg.in/ldap.v3 v3.1.0 h1:DIDWEjI7vQWREh0S8X5/NFPCZ3MCVd55LmXKPW4XLGE=
|
||||
gopkg.in/ldap.v3 v3.1.0/go.mod h1:dQjCc0R0kfyFjIlWNMH1DORwUASZyDxo2Ry1B51dXaQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
|
||||
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
@@ -1 +0,0 @@
|
||||
ref: refs/heads/master
|
||||
@@ -1,5 +0,0 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
@@ -1 +0,0 @@
|
||||
Unnamed repository; edit this file 'description' to name the repository.
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to check the commit log message taken by
|
||||
# applypatch from an e-mail message.
|
||||
#
|
||||
# The hook should exit with non-zero status after issuing an
|
||||
# appropriate message if it wants to stop the commit. The hook is
|
||||
# allowed to edit the commit message file.
|
||||
#
|
||||
# To enable this hook, rename this file to "applypatch-msg".
|
||||
|
||||
. git-sh-setup
|
||||
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
|
||||
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
|
||||
:
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to check the commit log message.
|
||||
# Called by "git commit" with one argument, the name of the file
|
||||
# that has the commit message. The hook should exit with non-zero
|
||||
# status after issuing an appropriate message if it wants to stop the
|
||||
# commit. The hook is allowed to edit the commit message file.
|
||||
#
|
||||
# To enable this hook, rename this file to "commit-msg".
|
||||
|
||||
# Uncomment the below to add a Signed-off-by line to the message.
|
||||
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
|
||||
# hook is more suited to it.
|
||||
#
|
||||
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
||||
|
||||
# This example catches duplicate Signed-off-by lines.
|
||||
|
||||
test "" = "$(grep '^Signed-off-by: ' "$1" |
|
||||
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
||||
echo >&2 Duplicate Signed-off-by lines.
|
||||
exit 1
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use IPC::Open2;
|
||||
|
||||
# An example hook script to integrate Watchman
|
||||
# (https://facebook.github.io/watchman/) with git to speed up detecting
|
||||
# new and modified files.
|
||||
#
|
||||
# The hook is passed a version (currently 1) and a time in nanoseconds
|
||||
# formatted as a string and outputs to stdout all files that have been
|
||||
# modified since the given time. Paths must be relative to the root of
|
||||
# the working tree and separated by a single NUL.
|
||||
#
|
||||
# To enable this hook, rename this file to "query-watchman" and set
|
||||
# 'git config core.fsmonitor .git/hooks/query-watchman'
|
||||
#
|
||||
my ($version, $time) = @ARGV;
|
||||
|
||||
# Check the hook interface version
|
||||
|
||||
if ($version == 1) {
|
||||
# convert nanoseconds to seconds
|
||||
$time = int $time / 1000000000;
|
||||
} else {
|
||||
die "Unsupported query-fsmonitor hook version '$version'.\n" .
|
||||
"Falling back to scanning...\n";
|
||||
}
|
||||
|
||||
my $git_work_tree;
|
||||
if ($^O =~ 'msys' || $^O =~ 'cygwin') {
|
||||
$git_work_tree = Win32::GetCwd();
|
||||
$git_work_tree =~ tr/\\/\//;
|
||||
} else {
|
||||
require Cwd;
|
||||
$git_work_tree = Cwd::cwd();
|
||||
}
|
||||
|
||||
my $retry = 1;
|
||||
|
||||
launch_watchman();
|
||||
|
||||
sub launch_watchman {
|
||||
|
||||
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
|
||||
or die "open2() failed: $!\n" .
|
||||
"Falling back to scanning...\n";
|
||||
|
||||
# In the query expression below we're asking for names of files that
|
||||
# changed since $time but were not transient (ie created after
|
||||
# $time but no longer exist).
|
||||
#
|
||||
# To accomplish this, we're using the "since" generator to use the
|
||||
# recency index to select candidate nodes and "fields" to limit the
|
||||
# output to file names only. Then we're using the "expression" term to
|
||||
# further constrain the results.
|
||||
#
|
||||
# The category of transient files that we want to ignore will have a
|
||||
# creation clock (cclock) newer than $time_t value and will also not
|
||||
# currently exist.
|
||||
|
||||
my $query = <<" END";
|
||||
["query", "$git_work_tree", {
|
||||
"since": $time,
|
||||
"fields": ["name"],
|
||||
"expression": ["not", ["allof", ["since", $time, "cclock"], ["not", "exists"]]]
|
||||
}]
|
||||
END
|
||||
|
||||
print CHLD_IN $query;
|
||||
close CHLD_IN;
|
||||
my $response = do {local $/; <CHLD_OUT>};
|
||||
|
||||
die "Watchman: command returned no output.\n" .
|
||||
"Falling back to scanning...\n" if $response eq "";
|
||||
die "Watchman: command returned invalid output: $response\n" .
|
||||
"Falling back to scanning...\n" unless $response =~ /^\{/;
|
||||
|
||||
my $json_pkg;
|
||||
eval {
|
||||
require JSON::XS;
|
||||
$json_pkg = "JSON::XS";
|
||||
1;
|
||||
} or do {
|
||||
require JSON::PP;
|
||||
$json_pkg = "JSON::PP";
|
||||
};
|
||||
|
||||
my $o = $json_pkg->new->utf8->decode($response);
|
||||
|
||||
if ($retry > 0 and $o->{error} and $o->{error} =~ m/unable to resolve root .* directory (.*) is not watched/) {
|
||||
print STDERR "Adding '$git_work_tree' to watchman's watch list.\n";
|
||||
$retry--;
|
||||
qx/watchman watch "$git_work_tree"/;
|
||||
die "Failed to make watchman watch '$git_work_tree'.\n" .
|
||||
"Falling back to scanning...\n" if $? != 0;
|
||||
|
||||
# Watchman will always return all files on the first query so
|
||||
# return the fast "everything is dirty" flag to git and do the
|
||||
# Watchman query just to get it over with now so we won't pay
|
||||
# the cost in git to look up each individual file.
|
||||
print "/\0";
|
||||
eval { launch_watchman() };
|
||||
exit 0;
|
||||
}
|
||||
|
||||
die "Watchman: $o->{error}.\n" .
|
||||
"Falling back to scanning...\n" if $o->{error};
|
||||
|
||||
binmode STDOUT, ":utf8";
|
||||
local $, = "\0";
|
||||
print @{$o->{files}};
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to prepare a packed repository for use over
|
||||
# dumb transports.
|
||||
#
|
||||
# To enable this hook, rename this file to "post-update".
|
||||
|
||||
exec git update-server-info
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed
|
||||
# by applypatch from an e-mail message.
|
||||
#
|
||||
# The hook should exit with non-zero status after issuing an
|
||||
# appropriate message if it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-applypatch".
|
||||
|
||||
. git-sh-setup
|
||||
precommit="$(git rev-parse --git-path hooks/pre-commit)"
|
||||
test -x "$precommit" && exec "$precommit" ${1+"$@"}
|
||||
:
|
||||
@@ -1,49 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-commit".
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||
then
|
||||
against=HEAD
|
||||
else
|
||||
# Initial commit: diff against an empty tree object
|
||||
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
||||
fi
|
||||
|
||||
# If you want to allow non-ASCII filenames set this variable to true.
|
||||
allownonascii=$(git config --bool hooks.allownonascii)
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
# Cross platform projects tend to avoid non-ASCII filenames; prevent
|
||||
# them from being added to the repository. We exploit the fact that the
|
||||
# printable range starts at the space character and ends with tilde.
|
||||
if [ "$allownonascii" != "true" ] &&
|
||||
# Note that the use of brackets around a tr range is ok here, (it's
|
||||
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
||||
# the square bracket bytes happen to fall in the designated range.
|
||||
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
||||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
||||
then
|
||||
cat <<\EOF
|
||||
Error: Attempt to add a non-ASCII file name.
|
||||
|
||||
This can cause problems if you want to work with people on other platforms.
|
||||
|
||||
To be portable it is advisable to rename the file.
|
||||
|
||||
If you know what you are doing you can disable this check using:
|
||||
|
||||
git config hooks.allownonascii true
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If there are whitespace errors, print the offending file names and fail.
|
||||
exec git diff-index --check --cached $against --
|
||||
@@ -1,53 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# An example hook script to verify what is about to be pushed. Called by "git
|
||||
# push" after it has checked the remote status, but before anything has been
|
||||
# pushed. If this script exits with a non-zero status nothing will be pushed.
|
||||
#
|
||||
# This hook is called with the following parameters:
|
||||
#
|
||||
# $1 -- Name of the remote to which the push is being done
|
||||
# $2 -- URL to which the push is being done
|
||||
#
|
||||
# If pushing without using a named remote those arguments will be equal.
|
||||
#
|
||||
# Information about the commits which are being pushed is supplied as lines to
|
||||
# the standard input in the form:
|
||||
#
|
||||
# <local ref> <local sha1> <remote ref> <remote sha1>
|
||||
#
|
||||
# This sample shows how to prevent push of commits where the log message starts
|
||||
# with "WIP" (work in progress).
|
||||
|
||||
remote="$1"
|
||||
url="$2"
|
||||
|
||||
z40=0000000000000000000000000000000000000000
|
||||
|
||||
while read local_ref local_sha remote_ref remote_sha
|
||||
do
|
||||
if [ "$local_sha" = $z40 ]
|
||||
then
|
||||
# Handle delete
|
||||
:
|
||||
else
|
||||
if [ "$remote_sha" = $z40 ]
|
||||
then
|
||||
# New branch, examine all commits
|
||||
range="$local_sha"
|
||||
else
|
||||
# Update to existing branch, examine new commits
|
||||
range="$remote_sha..$local_sha"
|
||||
fi
|
||||
|
||||
# Check for WIP commit
|
||||
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
|
||||
if [ -n "$commit" ]
|
||||
then
|
||||
echo >&2 "Found WIP commit in $local_ref, not pushing"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -1,169 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2006, 2008 Junio C Hamano
|
||||
#
|
||||
# The "pre-rebase" hook is run just before "git rebase" starts doing
|
||||
# its job, and can prevent the command from running by exiting with
|
||||
# non-zero status.
|
||||
#
|
||||
# The hook is called with the following parameters:
|
||||
#
|
||||
# $1 -- the upstream the series was forked from.
|
||||
# $2 -- the branch being rebased (or empty when rebasing the current branch).
|
||||
#
|
||||
# This sample shows how to prevent topic branches that are already
|
||||
# merged to 'next' branch from getting rebased, because allowing it
|
||||
# would result in rebasing already published history.
|
||||
|
||||
publish=next
|
||||
basebranch="$1"
|
||||
if test "$#" = 2
|
||||
then
|
||||
topic="refs/heads/$2"
|
||||
else
|
||||
topic=`git symbolic-ref HEAD` ||
|
||||
exit 0 ;# we do not interrupt rebasing detached HEAD
|
||||
fi
|
||||
|
||||
case "$topic" in
|
||||
refs/heads/??/*)
|
||||
;;
|
||||
*)
|
||||
exit 0 ;# we do not interrupt others.
|
||||
;;
|
||||
esac
|
||||
|
||||
# Now we are dealing with a topic branch being rebased
|
||||
# on top of master. Is it OK to rebase it?
|
||||
|
||||
# Does the topic really exist?
|
||||
git show-ref -q "$topic" || {
|
||||
echo >&2 "No such branch $topic"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Is topic fully merged to master?
|
||||
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
|
||||
if test -z "$not_in_master"
|
||||
then
|
||||
echo >&2 "$topic is fully merged to master; better remove it."
|
||||
exit 1 ;# we could allow it, but there is no point.
|
||||
fi
|
||||
|
||||
# Is topic ever merged to next? If so you should not be rebasing it.
|
||||
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
|
||||
only_next_2=`git rev-list ^master ${publish} | sort`
|
||||
if test "$only_next_1" = "$only_next_2"
|
||||
then
|
||||
not_in_topic=`git rev-list "^$topic" master`
|
||||
if test -z "$not_in_topic"
|
||||
then
|
||||
echo >&2 "$topic is already up to date with master"
|
||||
exit 1 ;# we could allow it, but there is no point.
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
|
||||
/usr/bin/perl -e '
|
||||
my $topic = $ARGV[0];
|
||||
my $msg = "* $topic has commits already merged to public branch:\n";
|
||||
my (%not_in_next) = map {
|
||||
/^([0-9a-f]+) /;
|
||||
($1 => 1);
|
||||
} split(/\n/, $ARGV[1]);
|
||||
for my $elem (map {
|
||||
/^([0-9a-f]+) (.*)$/;
|
||||
[$1 => $2];
|
||||
} split(/\n/, $ARGV[2])) {
|
||||
if (!exists $not_in_next{$elem->[0]}) {
|
||||
if ($msg) {
|
||||
print STDERR $msg;
|
||||
undef $msg;
|
||||
}
|
||||
print STDERR " $elem->[1]\n";
|
||||
}
|
||||
}
|
||||
' "$topic" "$not_in_next" "$not_in_master"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
<<\DOC_END
|
||||
|
||||
This sample hook safeguards topic branches that have been
|
||||
published from being rewound.
|
||||
|
||||
The workflow assumed here is:
|
||||
|
||||
* Once a topic branch forks from "master", "master" is never
|
||||
merged into it again (either directly or indirectly).
|
||||
|
||||
* Once a topic branch is fully cooked and merged into "master",
|
||||
it is deleted. If you need to build on top of it to correct
|
||||
earlier mistakes, a new topic branch is created by forking at
|
||||
the tip of the "master". This is not strictly necessary, but
|
||||
it makes it easier to keep your history simple.
|
||||
|
||||
* Whenever you need to test or publish your changes to topic
|
||||
branches, merge them into "next" branch.
|
||||
|
||||
The script, being an example, hardcodes the publish branch name
|
||||
to be "next", but it is trivial to make it configurable via
|
||||
$GIT_DIR/config mechanism.
|
||||
|
||||
With this workflow, you would want to know:
|
||||
|
||||
(1) ... if a topic branch has ever been merged to "next". Young
|
||||
topic branches can have stupid mistakes you would rather
|
||||
clean up before publishing, and things that have not been
|
||||
merged into other branches can be easily rebased without
|
||||
affecting other people. But once it is published, you would
|
||||
not want to rewind it.
|
||||
|
||||
(2) ... if a topic branch has been fully merged to "master".
|
||||
Then you can delete it. More importantly, you should not
|
||||
build on top of it -- other people may already want to
|
||||
change things related to the topic as patches against your
|
||||
"master", so if you need further changes, it is better to
|
||||
fork the topic (perhaps with the same name) afresh from the
|
||||
tip of "master".
|
||||
|
||||
Let's look at this example:
|
||||
|
||||
o---o---o---o---o---o---o---o---o---o "next"
|
||||
/ / / /
|
||||
/ a---a---b A / /
|
||||
/ / / /
|
||||
/ / c---c---c---c B /
|
||||
/ / / \ /
|
||||
/ / / b---b C \ /
|
||||
/ / / / \ /
|
||||
---o---o---o---o---o---o---o---o---o---o---o "master"
|
||||
|
||||
|
||||
A, B and C are topic branches.
|
||||
|
||||
* A has one fix since it was merged up to "next".
|
||||
|
||||
* B has finished. It has been fully merged up to "master" and "next",
|
||||
and is ready to be deleted.
|
||||
|
||||
* C has not merged to "next" at all.
|
||||
|
||||
We would want to allow C to be rebased, refuse A, and encourage
|
||||
B to be deleted.
|
||||
|
||||
To compute (1):
|
||||
|
||||
git rev-list ^master ^topic next
|
||||
git rev-list ^master next
|
||||
|
||||
if these match, topic has not merged in next at all.
|
||||
|
||||
To compute (2):
|
||||
|
||||
git rev-list master..topic
|
||||
|
||||
if this is empty, it is fully merged to "master".
|
||||
|
||||
DOC_END
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to make use of push options.
|
||||
# The example simply echoes all push options that start with 'echoback='
|
||||
# and rejects all pushes when the "reject" push option is used.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-receive".
|
||||
|
||||
if test -n "$GIT_PUSH_OPTION_COUNT"
|
||||
then
|
||||
i=0
|
||||
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
|
||||
do
|
||||
eval "value=\$GIT_PUSH_OPTION_$i"
|
||||
case "$value" in
|
||||
echoback=*)
|
||||
echo "echo from the pre-receive-hook: ${value#*=}" >&2
|
||||
;;
|
||||
reject)
|
||||
exit 1
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
fi
|
||||
@@ -1,42 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to prepare the commit log message.
|
||||
# Called by "git commit" with the name of the file that has the
|
||||
# commit message, followed by the description of the commit
|
||||
# message's source. The hook's purpose is to edit the commit
|
||||
# message file. If the hook fails with a non-zero status,
|
||||
# the commit is aborted.
|
||||
#
|
||||
# To enable this hook, rename this file to "prepare-commit-msg".
|
||||
|
||||
# This hook includes three examples. The first one removes the
|
||||
# "# Please enter the commit message..." help message.
|
||||
#
|
||||
# The second includes the output of "git diff --name-status -r"
|
||||
# into the message, just before the "git status" output. It is
|
||||
# commented because it doesn't cope with --amend or with squashed
|
||||
# commits.
|
||||
#
|
||||
# The third example adds a Signed-off-by line to the message, that can
|
||||
# still be edited. This is rarely a good idea.
|
||||
|
||||
COMMIT_MSG_FILE=$1
|
||||
COMMIT_SOURCE=$2
|
||||
SHA1=$3
|
||||
|
||||
/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
|
||||
|
||||
# case "$COMMIT_SOURCE,$SHA1" in
|
||||
# ,|template,)
|
||||
# /usr/bin/perl -i.bak -pe '
|
||||
# print "\n" . `git diff --cached --name-status -r`
|
||||
# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
|
||||
# *) ;;
|
||||
# esac
|
||||
|
||||
# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
|
||||
# if test -z "$COMMIT_SOURCE"
|
||||
# then
|
||||
# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
|
||||
# fi
|
||||
@@ -1,128 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script to block unannotated tags from entering.
|
||||
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
|
||||
#
|
||||
# To enable this hook, rename this file to "update".
|
||||
#
|
||||
# Config
|
||||
# ------
|
||||
# hooks.allowunannotated
|
||||
# This boolean sets whether unannotated tags will be allowed into the
|
||||
# repository. By default they won't be.
|
||||
# hooks.allowdeletetag
|
||||
# This boolean sets whether deleting tags will be allowed in the
|
||||
# repository. By default they won't be.
|
||||
# hooks.allowmodifytag
|
||||
# This boolean sets whether a tag may be modified after creation. By default
|
||||
# it won't be.
|
||||
# hooks.allowdeletebranch
|
||||
# This boolean sets whether deleting branches will be allowed in the
|
||||
# repository. By default they won't be.
|
||||
# hooks.denycreatebranch
|
||||
# This boolean sets whether remotely creating branches will be denied
|
||||
# in the repository. By default this is allowed.
|
||||
#
|
||||
|
||||
# --- Command line
|
||||
refname="$1"
|
||||
oldrev="$2"
|
||||
newrev="$3"
|
||||
|
||||
# --- Safety check
|
||||
if [ -z "$GIT_DIR" ]; then
|
||||
echo "Don't run this script from the command line." >&2
|
||||
echo " (if you want, you could supply GIT_DIR then run" >&2
|
||||
echo " $0 <ref> <oldrev> <newrev>)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
|
||||
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Config
|
||||
allowunannotated=$(git config --bool hooks.allowunannotated)
|
||||
allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
|
||||
denycreatebranch=$(git config --bool hooks.denycreatebranch)
|
||||
allowdeletetag=$(git config --bool hooks.allowdeletetag)
|
||||
allowmodifytag=$(git config --bool hooks.allowmodifytag)
|
||||
|
||||
# check for no description
|
||||
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
|
||||
case "$projectdesc" in
|
||||
"Unnamed repository"* | "")
|
||||
echo "*** Project description file hasn't been set" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- Check types
|
||||
# if $newrev is 0000...0000, it's a commit to delete a ref.
|
||||
zero="0000000000000000000000000000000000000000"
|
||||
if [ "$newrev" = "$zero" ]; then
|
||||
newrev_type=delete
|
||||
else
|
||||
newrev_type=$(git cat-file -t $newrev)
|
||||
fi
|
||||
|
||||
case "$refname","$newrev_type" in
|
||||
refs/tags/*,commit)
|
||||
# un-annotated tag
|
||||
short_refname=${refname##refs/tags/}
|
||||
if [ "$allowunannotated" != "true" ]; then
|
||||
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
|
||||
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,delete)
|
||||
# delete tag
|
||||
if [ "$allowdeletetag" != "true" ]; then
|
||||
echo "*** Deleting a tag is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/tags/*,tag)
|
||||
# annotated tag
|
||||
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
|
||||
then
|
||||
echo "*** Tag '$refname' already exists." >&2
|
||||
echo "*** Modifying a tag is not allowed in this repository." >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,commit)
|
||||
# branch
|
||||
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
|
||||
echo "*** Creating a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/heads/*,delete)
|
||||
# delete branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
refs/remotes/*,commit)
|
||||
# tracking branch
|
||||
;;
|
||||
refs/remotes/*,delete)
|
||||
# delete tracking branch
|
||||
if [ "$allowdeletebranch" != "true" ]; then
|
||||
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# Anything else (is there anything else?)
|
||||
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# --- Finished
|
||||
exit 0
|
||||
@@ -1,6 +0,0 @@
|
||||
# git ls-files --others --exclude-from=.git/info/exclude
|
||||
# Lines that start with '#' are comments.
|
||||
# For a project mostly in C, the following would be a good set of
|
||||
# exclude patterns (uncomment them if you want to use them):
|
||||
# *.[oa]
|
||||
# *~
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/nabbar/golib/njs-certif"
|
||||
"github.com/nabbar/golib/njs-logger"
|
||||
"gopkg.in/ldap.v2"
|
||||
"gopkg.in/ldap.v3"
|
||||
)
|
||||
|
||||
//HelperLDAP struct use to manage connection to server and request it
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019 Nicolas JUHEL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
package njs_ldap_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/nabbar/golib/njs-logger"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/nabbar/golib/njs-ldap"
|
||||
"github.com/nabbar/golib/njs-ldap/ldaptestserver"
|
||||
)
|
||||
|
||||
var (
|
||||
ldap *njs_ldap.HelperLDAP
|
||||
conf *njs_ldap.Config
|
||||
)
|
||||
|
||||
func init() {
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
filepath := dir + "/test.yml"
|
||||
|
||||
if _, err := os.Stat(filepath); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
conf = njs_ldap.NewConfig()
|
||||
|
||||
if cnt, err := ioutil.ReadFile(filepath); err != nil {
|
||||
panic(err)
|
||||
} else if err := yaml.Unmarshal(cnt, &conf); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHelpers(t *testing.T) {
|
||||
njs_logger.InfoLevel.Log("Starting LDAP Test Server...")
|
||||
ldaptestserver.RunTestLDAPServer()
|
||||
|
||||
defer func() {
|
||||
if ldap != nil {
|
||||
ldap.Close()
|
||||
}
|
||||
ldaptestserver.StopTestLDAPServer()
|
||||
njs_logger.InfoLevel.Log("LDAP Test Server is stopped...")
|
||||
}()
|
||||
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Test Suite of Helpers LDAP")
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2019 Nicolas JUHEL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
package njs_ldap_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/nabbar/golib/njs-ldap"
|
||||
"github.com/nabbar/golib/njs-ldap/ldaptestserver"
|
||||
"github.com/nabbar/golib/njs-logger"
|
||||
)
|
||||
|
||||
var (
|
||||
username = ""
|
||||
grpAdmin = "Test - Group2"
|
||||
grpManager = "Test - Group3"
|
||||
userBindEr = "uid=false,dc=example,dc=com"
|
||||
userBindDn = "uid=" + ldaptestserver.GetTestAccountDN(ldaptestserver.TEST_ACCOUNT_TYPE_USER, ldaptestserver.TEST_ACCOUNT_ID_MAIN) + ",dc=example,dc=com"
|
||||
userBindPw = "abc123def"
|
||||
)
|
||||
|
||||
func init() {
|
||||
njs_logger.SetLevel(njs_logger.InfoLevel)
|
||||
}
|
||||
|
||||
var _ = Describe("Helpers Test: ", func() {
|
||||
Context("Test LDAP", func() {
|
||||
Context("having a false user connection", func() {
|
||||
BeforeEach(func() {
|
||||
ldap = njs_ldap.NewLDAP(conf, njs_ldap.GetDefaultAttributes())
|
||||
ldap.SetCredentials(userBindEr, userBindPw)
|
||||
})
|
||||
It("have a connected instance of helper ldap", func() {
|
||||
Expect(ldap).ToNot(BeNil())
|
||||
Expect(ldap.Connect()).To(HaveOccurred())
|
||||
})
|
||||
})
|
||||
Context("having a good user connection", func() {
|
||||
BeforeEach(func() {
|
||||
ldap = njs_ldap.NewLDAP(conf, njs_ldap.GetDefaultAttributes())
|
||||
ldap.SetCredentials(userBindDn, userBindPw)
|
||||
})
|
||||
It("have a connected instance of helper ldap", func() {
|
||||
Expect(ldap).ToNot(BeNil())
|
||||
Expect(ldap.Connect()).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
It("return an error on retrieve User Info of a false username", func() {
|
||||
usr, err := ldap.UserInfo("notExists")
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(usr).To(Equal(make(map[string]string)))
|
||||
})
|
||||
})
|
||||
Context("given a real username", func() {
|
||||
BeforeEach(func() {
|
||||
username = "Test2"
|
||||
ldap = njs_ldap.NewLDAP(conf, njs_ldap.GetDefaultAttributes())
|
||||
ldap.SetCredentials(userBindDn, userBindPw)
|
||||
})
|
||||
|
||||
It("have a connected instance of helper ldap", func() {
|
||||
Expect(ldap).ToNot(BeNil())
|
||||
Expect(ldap.Connect()).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
It("return the retrieved User Info", func() {
|
||||
usr, err := ldap.UserInfo("Test2")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(usr).ToNot(Equal(make(map[string]string)))
|
||||
Expect(usr["uid"]).To(Equal("Test2"))
|
||||
})
|
||||
|
||||
It("Return true and no error when check Is in Admin group", func() {
|
||||
chk, err := ldap.UserIsInGroup(username, []string{grpAdmin})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(chk).To(BeTrue())
|
||||
})
|
||||
|
||||
It("Return false and no error when check Is in Manager group", func() {
|
||||
chk, err := ldap.UserIsInGroup(username, []string{grpManager})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(chk).To(BeFalse())
|
||||
})
|
||||
|
||||
It("Return no error and the list when retrieve members of a group", func() {
|
||||
lst, err := ldap.UsersOfGroup("Test - Group1")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(len(lst)).To(Equal(3))
|
||||
})
|
||||
|
||||
Context("given a empty password", func() {
|
||||
It("return an error on authentificate with LDAP", func() {
|
||||
Expect(ldap.AuthUser("uid="+username, "")).To(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
Context("given a wrong password", func() {
|
||||
It("return no error but a false result when authentificate with LDAP", func() {
|
||||
Expect(ldap.AuthUser("uid="+username, "wrongPassword")).To(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
Context("given a good password", func() {
|
||||
It("return no error but a false result when authentificate with LDAP", func() {
|
||||
Expect(ldap.AuthUser("uid="+username, "abc123def")).ToNot(HaveOccurred())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
@@ -1,465 +0,0 @@
|
||||
package njs_ldap
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vjeantet/ldapserver"
|
||||
)
|
||||
|
||||
const (
|
||||
TEST_ACCOUNT_TYPE_USER = iota
|
||||
TEST_ACCOUNT_TYPE_GROUP
|
||||
)
|
||||
|
||||
const (
|
||||
TEST_ACCOUNT_ID_MAIN = iota
|
||||
TEST_ACCOUNT_ID_1
|
||||
TEST_ACCOUNT_ID_2
|
||||
TEST_ACCOUNT_ID_3
|
||||
)
|
||||
|
||||
const (
|
||||
TEST_ACCOUNT_VALID_PASSWORD = "abc123def"
|
||||
)
|
||||
|
||||
var (
|
||||
ch chan os.Signal
|
||||
testLDAPserver *ldapserver.Server
|
||||
)
|
||||
|
||||
func GetTestAccountDN(typeAccount int, idAccound int) string {
|
||||
switch typeAccount {
|
||||
case TEST_ACCOUNT_TYPE_GROUP:
|
||||
switch idAccound {
|
||||
case TEST_ACCOUNT_ID_1:
|
||||
return "Test - Group1"
|
||||
case TEST_ACCOUNT_ID_2:
|
||||
return "Test - Group2"
|
||||
case TEST_ACCOUNT_ID_3:
|
||||
return "Test - Group3"
|
||||
}
|
||||
case TEST_ACCOUNT_TYPE_USER:
|
||||
switch idAccound {
|
||||
case TEST_ACCOUNT_ID_1:
|
||||
return "Test1"
|
||||
case TEST_ACCOUNT_ID_2:
|
||||
return "Test2"
|
||||
case TEST_ACCOUNT_ID_3:
|
||||
return "Test3"
|
||||
case TEST_ACCOUNT_ID_MAIN:
|
||||
return "bindMainReadOnly"
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func RunTestLDAPServer() {
|
||||
//Create a new LDAP Server
|
||||
testLDAPserver = ldapserver.NewServer()
|
||||
|
||||
//Create routes bindings
|
||||
routes := ldapserver.NewRouteMux()
|
||||
routes.NotFound(handleNotFound)
|
||||
routes.Abandon(handleAbandon)
|
||||
routes.Bind(handleBind)
|
||||
routes.Compare(handleCompare)
|
||||
routes.Add(handleAdd)
|
||||
routes.Delete(handleDelete)
|
||||
routes.Modify(handleModify)
|
||||
routes.Extended(handleStartTLS).RequestName(ldapserver.NoticeOfStartTLS)
|
||||
routes.Extended(handleWhoAmI).RequestName(ldapserver.NoticeOfWhoAmI)
|
||||
|
||||
routes.Extended(handleExtended)
|
||||
|
||||
routes.Search(handleSearch)
|
||||
|
||||
//Attach routes to server
|
||||
testLDAPserver.Handle(routes)
|
||||
|
||||
ch = make(chan os.Signal)
|
||||
// listen on 10389 and serve
|
||||
go func() {
|
||||
defer ginkgo.GinkgoRecover()
|
||||
|
||||
if err := testLDAPserver.ListenAndServe("127.0.0.1:10389"); err != nil {
|
||||
logrus.Fatal("Error on LDAP Test Server : %v", err)
|
||||
}
|
||||
}()
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
|
||||
func StopTestLDAPServer() {
|
||||
// When CTRL+C, SIGINT and SIGTERM signal occurs
|
||||
// Then stop server gracefully
|
||||
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
|
||||
// <-ch
|
||||
time.Sleep(5 * time.Second)
|
||||
close(ch)
|
||||
testLDAPserver.Stop()
|
||||
}
|
||||
|
||||
func handleNotFound(w ldapserver.ResponseWriter, r *ldapserver.Message) {
|
||||
switch r.GetProtocolOp() {
|
||||
case ldapserver.ApplicationBindRequest:
|
||||
res := ldapserver.NewBindResponse(ldapserver.LDAPResultSuccess)
|
||||
res.DiagnosticMessage = "Default binding behavior set to return Success"
|
||||
|
||||
w.Write(res)
|
||||
|
||||
default:
|
||||
res := ldapserver.NewResponse(ldapserver.LDAPResultUnwillingToPerform)
|
||||
res.DiagnosticMessage = "Operation not implemented by server"
|
||||
w.Write(res)
|
||||
}
|
||||
}
|
||||
|
||||
func handleAbandon(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
var req = m.GetAbandonRequest()
|
||||
// retreive the request to abandon, and send a abort signal to it
|
||||
if requestToAbandon, ok := m.Client.GetMessageByID(int(req)); ok {
|
||||
requestToAbandon.Abandon()
|
||||
//logrus.Infof("Abandon signal sent to request processor [messageID=%d]", int(req))
|
||||
}
|
||||
}
|
||||
|
||||
func handleBind(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
res := ldapserver.NewBindResponse(ldapserver.LDAPResultSuccess)
|
||||
r := m.GetBindRequest()
|
||||
//logrus.Debugf("Calling Bind Request for : User=%s, Pass=%#v", string(r.GetLogin()), string(r.GetPassword()))
|
||||
|
||||
if string(r.GetPassword()) == TEST_ACCOUNT_VALID_PASSWORD {
|
||||
switch string(r.GetLogin()) {
|
||||
case fmt.Sprintf("uid=%s", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_MAIN)),
|
||||
fmt.Sprintf("uid=%s", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_1)),
|
||||
fmt.Sprintf("uid=%s", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_2)),
|
||||
fmt.Sprintf("uid=%s", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_3)),
|
||||
fmt.Sprintf("uid=%s,dc=example,dc=com", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_MAIN)),
|
||||
fmt.Sprintf("uid=%s,dc=example,dc=com", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_1)),
|
||||
fmt.Sprintf("uid=%s,dc=example,dc=com", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_2)),
|
||||
fmt.Sprintf("uid=%s,dc=example,dc=com", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_3)):
|
||||
w.Write(res)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
//logrus.Debugf("Bind failed User=%s, Pass=%s", string(r.GetLogin()), string(r.GetPassword()))
|
||||
res.ResultCode = ldapserver.LDAPResultInvalidCredentials
|
||||
res.DiagnosticMessage = "invalid credentials"
|
||||
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
// The resultCode is set to compareTrue, compareFalse, or an appropriate
|
||||
// error. compareTrue indicates that the assertion value in the ava
|
||||
// Comparerequest field matches a value of the attribute or subtype according to the
|
||||
// attribute's EQUALITY matching rule. compareFalse indicates that the
|
||||
// assertion value in the ava field and the values of the attribute or
|
||||
// subtype did not match. Other result codes indicate either that the
|
||||
// result of the comparison was Undefined, or that
|
||||
// some error occurred.
|
||||
func handleCompare(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
/*
|
||||
r := m.GetCompareRequest()
|
||||
logrus.Debugf("Comparing entry: %s", r.GetEntry())
|
||||
//attributes values
|
||||
logrus.Debugf(" attribute name to compare : \"%s\"", r.GetAttributeValueAssertion().GetName())
|
||||
logrus.Debugf(" attribute value expected : \"%s\"", r.GetAttributeValueAssertion().GetValue())
|
||||
*/
|
||||
|
||||
res := ldapserver.NewCompareResponse(ldapserver.LDAPResultCompareTrue)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleAdd(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
/*
|
||||
r := m.GetAddRequest()
|
||||
logrus.Debugf("Adding entry: %s", r.GetEntryDN())
|
||||
//attributes values
|
||||
for _, attribute := range r.GetAttributes() {
|
||||
for _, attributeValue := range attribute.GetValues() {
|
||||
logrus.Debugf("- %s:%s", attribute.GetDescription(), attributeValue)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
res := ldapserver.NewAddResponse(ldapserver.LDAPResultSuccess)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleModify(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
/*
|
||||
r := m.GetModifyRequest()
|
||||
logrus.Debugf("Modify entry: %s", r.GetObject())
|
||||
|
||||
for _, change := range r.GetChanges() {
|
||||
modification := change.GetModification()
|
||||
var operationString string
|
||||
switch change.GetOperation() {
|
||||
case ldapserver.ModifyRequestChangeOperationAdd:
|
||||
operationString = "Add"
|
||||
case ldapserver.ModifyRequestChangeOperationDelete:
|
||||
operationString = "Delete"
|
||||
case ldapserver.ModifyRequestChangeOperationReplace:
|
||||
operationString = "Replace"
|
||||
}
|
||||
|
||||
|
||||
logrus.Debugf("%s attribute '%s'", operationString, modification.GetDescription())
|
||||
for _, attributeValue := range modification.GetValues() {
|
||||
logrus.Debugf("- value: %s", attributeValue)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
res := ldapserver.NewModifyResponse(ldapserver.LDAPResultSuccess)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleDelete(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
/*
|
||||
r := m.GetDeleteRequest()
|
||||
logrus.Debugf("Deleting entry: %s", r)
|
||||
*/
|
||||
res := ldapserver.NewDeleteResponse(ldapserver.LDAPResultSuccess)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleExtended(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
/*
|
||||
r := m.GetExtendedRequest()
|
||||
logrus.Debugf("Extended request received, name=%s", r.GetResponseName())
|
||||
logrus.Debugf("Extended request received, value=%x", r.GetResponseValue())
|
||||
*/
|
||||
res := ldapserver.NewExtendedResponse(ldapserver.LDAPResultSuccess)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleWhoAmI(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
res := ldapserver.NewExtendedResponse(ldapserver.LDAPResultSuccess)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleSearchDSE(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
r := m.GetSearchRequest()
|
||||
|
||||
attr := make([]string, 0)
|
||||
for _, v := range r.GetAttributes() {
|
||||
attr = append(attr, string(v))
|
||||
}
|
||||
|
||||
/*
|
||||
logrus.Debugf("Request BaseDn=%s", r.GetBaseObject())
|
||||
logrus.Debugf("Request Filter=%s", r.GetFilter())
|
||||
logrus.Debugf("Request Attributes=%s", strings.Join(attr, ","))
|
||||
logrus.Debugf("Request TimeLimit=%d", r.GetTimeLimit())
|
||||
*/
|
||||
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.AddAttribute("vendorName", "Test Vendor")
|
||||
e.AddAttribute("vendorVersion", "0.0.1")
|
||||
e.AddAttribute("objectClass", "top", "extensibleObject")
|
||||
e.AddAttribute("supportedLDAPVersion", "3")
|
||||
e.AddAttribute("namingContexts", "o=Test Company, c=US")
|
||||
w.Write(e)
|
||||
|
||||
res := ldapserver.NewSearchResultDoneResponse(ldapserver.LDAPResultSuccess)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleSearchMyCompany(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
r := m.GetSearchRequest()
|
||||
//logrus.Debugf("handleSearchMyCompany - Request BaseDn=%s", r.GetBaseObject())
|
||||
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.SetDn(string(r.GetBaseObject()))
|
||||
e.AddAttribute("objectClass", "top", "organizationalUnit")
|
||||
w.Write(e)
|
||||
|
||||
res := ldapserver.NewSearchResultDoneResponse(ldapserver.LDAPResultSuccess)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleSearch(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
r := m.GetSearchRequest()
|
||||
|
||||
if string(r.GetBaseObject()) == "" && r.GetScope() == ldapserver.SearchRequestScopeBaseObject && r.GetFilter() == "(objectclass=*)" {
|
||||
handleSearchDSE(w, m)
|
||||
return
|
||||
}
|
||||
|
||||
if string(r.GetBaseObject()) == "o=My Company, c=US" && r.GetScope() == ldapserver.SearchRequestScopeBaseObject {
|
||||
handleSearchMyCompany(w, m)
|
||||
return
|
||||
}
|
||||
|
||||
attr := make([]string, 0)
|
||||
for _, v := range r.GetAttributes() {
|
||||
attr = append(attr, string(v))
|
||||
}
|
||||
|
||||
/*
|
||||
logrus.Debugf("Request BaseDn=%s", string(r.GetBaseObject()))
|
||||
logrus.Debugf("Request Filter=%s", r.GetFilter())
|
||||
logrus.Debugf("Request Attributes=%s", strings.Join(attr, ","))
|
||||
logrus.Debugf("Request TimeLimit=%d", r.GetTimeLimit())
|
||||
*/
|
||||
|
||||
// Handle Stop Signal (server stop / client disconnected / Abandoned request....)
|
||||
select {
|
||||
case <-m.Done:
|
||||
//logrus.Info("Leaving handleSearch...")
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
if r.GetFilter() == "(uid=Test1)" {
|
||||
//logrus.Debugf("Prepare Result Test1 for %s", r.GetFilter())
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.SetDn("uid=Test1," + string(r.GetBaseObject()))
|
||||
e.AddAttribute("mail", "test.ldap@example.com", "testldap@example.com")
|
||||
e.AddAttribute("uid", "Test1")
|
||||
e.AddAttribute("cn", "Test1")
|
||||
e.AddAttribute("ou", "People")
|
||||
e.AddAttribute("dc", "example", "com")
|
||||
e.AddAttribute("memberOf", "cn=Test - Group1,dc=example,dc=com", "cn=Test - Group2,dc=example,dc=com", "cn=Test - Group3,dc=example,dc=com")
|
||||
w.Write(e)
|
||||
}
|
||||
|
||||
if r.GetFilter() == "(uid=Test2)" {
|
||||
//logrus.Debugf("Prepare Result Test2 for %s", r.GetFilter())
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.SetDn("uid=Test2," + string(r.GetBaseObject()))
|
||||
e.AddAttribute("mail", "test.2.ldap@example.com")
|
||||
e.AddAttribute("uid", "Test2")
|
||||
e.AddAttribute("cn", "Test2")
|
||||
e.AddAttribute("ou", "People")
|
||||
e.AddAttribute("dc", "example", "com")
|
||||
e.AddAttribute("memberOf", "cn=Test - Group1,dc=example,dc=com", "cn=Test - Group2,dc=example,dc=com")
|
||||
w.Write(e)
|
||||
}
|
||||
|
||||
if r.GetFilter() == "(uid=Test3)" {
|
||||
//logrus.Debugf("Prepare Result Test3 for %s", r.GetFilter())
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.SetDn("uid=Test3," + string(r.GetBaseObject()))
|
||||
e.AddAttribute("mail", "test.3.ldap@example.com")
|
||||
e.AddAttribute("uid", "Test3")
|
||||
e.AddAttribute("cn", "Test3")
|
||||
e.AddAttribute("ou", "People")
|
||||
e.AddAttribute("dc", "example", "com")
|
||||
e.AddAttribute("memberOf", "cn=Test - Group1,dc=example,dc=com", "cn=Test - Group3,dc=example,dc=com")
|
||||
w.Write(e)
|
||||
}
|
||||
|
||||
if r.GetFilter() == "(&(objectClass=groupOfNames)(cn=Test - Group1))" {
|
||||
//logrus.Debugf("Prepare Result [Test - Group1] for %s", r.GetFilter())
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.SetDn("uid=Test - Group1," + string(r.GetBaseObject()))
|
||||
e.AddAttribute("cn", "Test - Group1")
|
||||
e.AddAttribute("ou", "Group")
|
||||
e.AddAttribute("dc", "example", "com")
|
||||
e.AddAttribute("member", "uid=Test1,dc=example,dc=com", "uid=Test2,dc=example,dc=com", "uid=Test3,dc=example,dc=com")
|
||||
w.Write(e)
|
||||
}
|
||||
|
||||
if r.GetFilter() == "(&(objectClass=groupOfNames)(cn=Test - Group2))" {
|
||||
//logrus.Debugf("Prepare Result [Test - Group2] for %s", r.GetFilter())
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.SetDn("uid=Test - Group2," + string(r.GetBaseObject()))
|
||||
e.AddAttribute("cn", "Test - Group2")
|
||||
e.AddAttribute("ou", "Group")
|
||||
e.AddAttribute("dc", "example", "com")
|
||||
e.AddAttribute("member", "uid=Test1,dc=example,dc=com", "uid=Test3,dc=example,dc=com")
|
||||
w.Write(e)
|
||||
}
|
||||
|
||||
if r.GetFilter() == "(&(objectClass=groupOfNames)(cn=Test - Group3))" {
|
||||
//logrus.Debugf("Prepare Result [Test - Group3] for %s", r.GetFilter())
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.SetDn("uid=Test - Group3," + string(r.GetBaseObject()))
|
||||
e.AddAttribute("cn", "Test - Group3")
|
||||
e.AddAttribute("ou", "Group")
|
||||
e.AddAttribute("dc", "example", "com")
|
||||
e.AddAttribute("member", "uid=Test1,dc=example,dc=com", "uid=Test2,dc=example,dc=com")
|
||||
w.Write(e)
|
||||
}
|
||||
|
||||
res := ldapserver.NewSearchResultDoneResponse(ldapserver.LDAPResultSuccess)
|
||||
|
||||
//logrus.Debugf("Res Found : %v", res)
|
||||
w.Write(res)
|
||||
|
||||
}
|
||||
|
||||
// localhostCert is a PEM-encoded TLS cert with SAN DNS names
|
||||
// "127.0.0.1" and "[::1]", expiring at the last second of 2049 (the end
|
||||
// of ASN.1 time).
|
||||
var localhostCert = []byte(`-----BEGIN CERTIFICATE-----
|
||||
MIIBOTCB5qADAgECAgEAMAsGCSqGSIb3DQEBBTAAMB4XDTcwMDEwMTAwMDAwMFoX
|
||||
DTQ5MTIzMTIzNTk1OVowADBaMAsGCSqGSIb3DQEBAQNLADBIAkEAsuA5mAFMj6Q7
|
||||
qoBzcvKzIq4kzuT5epSp2AkcQfyBHm7K13Ws7u+0b5Vb9gqTf5cAiIKcrtrXVqkL
|
||||
8i1UQF6AzwIDAQABo08wTTAOBgNVHQ8BAf8EBAMCACQwDQYDVR0OBAYEBAECAwQw
|
||||
DwYDVR0jBAgwBoAEAQIDBDAbBgNVHREEFDASggkxMjcuMC4wLjGCBVs6OjFdMAsG
|
||||
CSqGSIb3DQEBBQNBAJH30zjLWRztrWpOCgJL8RQWLaKzhK79pVhAx6q/3NrF16C7
|
||||
+l1BRZstTwIGdoGId8BRpErK1TXkniFb95ZMynM=
|
||||
-----END CERTIFICATE-----
|
||||
`)
|
||||
|
||||
// localhostKey is the private key for localhostCert.
|
||||
var localhostKey = []byte(`-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIBPQIBAAJBALLgOZgBTI+kO6qAc3LysyKuJM7k+XqUqdgJHEH8gR5uytd1rO7v
|
||||
tG+VW/YKk3+XAIiCnK7a11apC/ItVEBegM8CAwEAAQJBAI5sxq7naeR9ahyqRkJi
|
||||
SIv2iMxLuPEHaezf5CYOPWjSjBPyVhyRevkhtqEjF/WkgL7C2nWpYHsUcBDBQVF0
|
||||
3KECIQDtEGB2ulnkZAahl3WuJziXGLB+p8Wgx7wzSM6bHu1c6QIhAMEp++CaS+SJ
|
||||
/TrU0zwY/fW4SvQeb49BPZUF3oqR8Xz3AiEA1rAJHBzBgdOQKdE3ksMUPcnvNJSN
|
||||
poCcELmz2clVXtkCIQCLytuLV38XHToTipR4yMl6O+6arzAjZ56uq7m7ZRV0TwIh
|
||||
AM65XAOw8Dsg9Kq78aYXiOEDc5DL0sbFUu/SlmRcCg93
|
||||
-----END RSA PRIVATE KEY-----
|
||||
`)
|
||||
|
||||
// getTLSconfig returns a tls configuration used
|
||||
// to build a TLSlistener for TLS or StartTLS
|
||||
func getTLSconfig() (*tls.Config, error) {
|
||||
cert, err := tls.X509KeyPair(localhostCert, localhostKey)
|
||||
if err != nil {
|
||||
return &tls.Config{}, err
|
||||
}
|
||||
|
||||
return &tls.Config{
|
||||
MinVersion: tls.VersionTLS12,
|
||||
MaxVersion: tls.VersionTLS12,
|
||||
Certificates: []tls.Certificate{cert},
|
||||
ServerName: "127.0.0.1",
|
||||
}, nil
|
||||
}
|
||||
|
||||
func handleStartTLS(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
tlsconfig, e := getTLSconfig()
|
||||
if e != nil {
|
||||
logrus.Errorf("error while retrieve TLS config: %v", e)
|
||||
}
|
||||
|
||||
tlsConn := tls.Server(m.Client.GetConn(), tlsconfig)
|
||||
res := ldapserver.NewExtendedResponse(ldapserver.LDAPResultSuccess)
|
||||
res.ResponseName = ldapserver.NoticeOfStartTLS
|
||||
w.Write(res)
|
||||
|
||||
if err := tlsConn.Handshake(); err != nil {
|
||||
logrus.Errorf("StartTLS Handshake error %v", err)
|
||||
res.DiagnosticMessage = fmt.Sprintf("StartTLS Handshake error : \"%s\"", err.Error())
|
||||
res.ResultCode = ldapserver.LDAPResultOperationsError
|
||||
w.Write(res)
|
||||
return
|
||||
}
|
||||
|
||||
m.Client.SetConn(tlsConn)
|
||||
logrus.Info("StartTLS OK")
|
||||
}
|
||||
@@ -1,465 +0,0 @@
|
||||
package ldaptestserver
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vjeantet/ldapserver"
|
||||
)
|
||||
|
||||
const (
|
||||
TEST_ACCOUNT_TYPE_USER = iota
|
||||
TEST_ACCOUNT_TYPE_GROUP
|
||||
)
|
||||
|
||||
const (
|
||||
TEST_ACCOUNT_ID_MAIN = iota
|
||||
TEST_ACCOUNT_ID_1
|
||||
TEST_ACCOUNT_ID_2
|
||||
TEST_ACCOUNT_ID_3
|
||||
)
|
||||
|
||||
const (
|
||||
TEST_ACCOUNT_VALID_PASSWORD = "abc123def"
|
||||
)
|
||||
|
||||
var (
|
||||
ch chan os.Signal
|
||||
testLDAPserver *ldapserver.Server
|
||||
)
|
||||
|
||||
func GetTestAccountDN(typeAccount int, idAccound int) string {
|
||||
switch typeAccount {
|
||||
case TEST_ACCOUNT_TYPE_GROUP:
|
||||
switch idAccound {
|
||||
case TEST_ACCOUNT_ID_1:
|
||||
return "Test - Group1"
|
||||
case TEST_ACCOUNT_ID_2:
|
||||
return "Test - Group2"
|
||||
case TEST_ACCOUNT_ID_3:
|
||||
return "Test - Group3"
|
||||
}
|
||||
case TEST_ACCOUNT_TYPE_USER:
|
||||
switch idAccound {
|
||||
case TEST_ACCOUNT_ID_1:
|
||||
return "Test1"
|
||||
case TEST_ACCOUNT_ID_2:
|
||||
return "Test2"
|
||||
case TEST_ACCOUNT_ID_3:
|
||||
return "Test3"
|
||||
case TEST_ACCOUNT_ID_MAIN:
|
||||
return "bindMainReadOnly"
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func RunTestLDAPServer() {
|
||||
//Create a new LDAP Server
|
||||
testLDAPserver = ldapserver.NewServer()
|
||||
|
||||
//Create routes bindings
|
||||
routes := ldapserver.NewRouteMux()
|
||||
routes.NotFound(handleNotFound)
|
||||
routes.Abandon(handleAbandon)
|
||||
routes.Bind(handleBind)
|
||||
routes.Compare(handleCompare)
|
||||
routes.Add(handleAdd)
|
||||
routes.Delete(handleDelete)
|
||||
routes.Modify(handleModify)
|
||||
routes.Extended(handleStartTLS).RequestName(ldapserver.NoticeOfStartTLS)
|
||||
routes.Extended(handleWhoAmI).RequestName(ldapserver.NoticeOfWhoAmI)
|
||||
|
||||
routes.Extended(handleExtended)
|
||||
|
||||
routes.Search(handleSearch)
|
||||
|
||||
//Attach routes to server
|
||||
testLDAPserver.Handle(routes)
|
||||
|
||||
ch = make(chan os.Signal)
|
||||
// listen on 10389 and serve
|
||||
go func() {
|
||||
defer ginkgo.GinkgoRecover()
|
||||
|
||||
if err := testLDAPserver.ListenAndServe("127.0.0.1:10389"); err != nil {
|
||||
logrus.Fatal("Error on LDAP Test Server : %v", err)
|
||||
}
|
||||
}()
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
|
||||
func StopTestLDAPServer() {
|
||||
// When CTRL+C, SIGINT and SIGTERM signal occurs
|
||||
// Then stop server gracefully
|
||||
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
|
||||
// <-ch
|
||||
time.Sleep(5 * time.Second)
|
||||
close(ch)
|
||||
testLDAPserver.Stop()
|
||||
}
|
||||
|
||||
func handleNotFound(w ldapserver.ResponseWriter, r *ldapserver.Message) {
|
||||
switch r.GetProtocolOp() {
|
||||
case ldapserver.ApplicationBindRequest:
|
||||
res := ldapserver.NewBindResponse(ldapserver.LDAPResultSuccess)
|
||||
res.DiagnosticMessage = "Default binding behavior set to return Success"
|
||||
|
||||
w.Write(res)
|
||||
|
||||
default:
|
||||
res := ldapserver.NewResponse(ldapserver.LDAPResultUnwillingToPerform)
|
||||
res.DiagnosticMessage = "Operation not implemented by server"
|
||||
w.Write(res)
|
||||
}
|
||||
}
|
||||
|
||||
func handleAbandon(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
var req = m.GetAbandonRequest()
|
||||
// retreive the request to abandon, and send a abort signal to it
|
||||
if requestToAbandon, ok := m.Client.GetMessageByID(int(req)); ok {
|
||||
requestToAbandon.Abandon()
|
||||
//logrus.Infof("Abandon signal sent to request processor [messageID=%d]", int(req))
|
||||
}
|
||||
}
|
||||
|
||||
func handleBind(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
res := ldapserver.NewBindResponse(ldapserver.LDAPResultSuccess)
|
||||
r := m.GetBindRequest()
|
||||
//logrus.Debugf("Calling Bind Request for : User=%s, Pass=%#v", string(r.GetLogin()), string(r.GetPassword()))
|
||||
|
||||
if string(r.GetPassword()) == TEST_ACCOUNT_VALID_PASSWORD {
|
||||
switch string(r.GetLogin()) {
|
||||
case fmt.Sprintf("uid=%s", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_MAIN)),
|
||||
fmt.Sprintf("uid=%s", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_1)),
|
||||
fmt.Sprintf("uid=%s", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_2)),
|
||||
fmt.Sprintf("uid=%s", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_3)),
|
||||
fmt.Sprintf("uid=%s,dc=example,dc=com", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_MAIN)),
|
||||
fmt.Sprintf("uid=%s,dc=example,dc=com", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_1)),
|
||||
fmt.Sprintf("uid=%s,dc=example,dc=com", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_2)),
|
||||
fmt.Sprintf("uid=%s,dc=example,dc=com", GetTestAccountDN(TEST_ACCOUNT_TYPE_USER, TEST_ACCOUNT_ID_3)):
|
||||
w.Write(res)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
//logrus.Debugf("Bind failed User=%s, Pass=%s", string(r.GetLogin()), string(r.GetPassword()))
|
||||
res.ResultCode = ldapserver.LDAPResultInvalidCredentials
|
||||
res.DiagnosticMessage = "invalid credentials"
|
||||
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
// The resultCode is set to compareTrue, compareFalse, or an appropriate
|
||||
// error. compareTrue indicates that the assertion value in the ava
|
||||
// Comparerequest field matches a value of the attribute or subtype according to the
|
||||
// attribute's EQUALITY matching rule. compareFalse indicates that the
|
||||
// assertion value in the ava field and the values of the attribute or
|
||||
// subtype did not match. Other result codes indicate either that the
|
||||
// result of the comparison was Undefined, or that
|
||||
// some error occurred.
|
||||
func handleCompare(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
/*
|
||||
r := m.GetCompareRequest()
|
||||
logrus.Debugf("Comparing entry: %s", r.GetEntry())
|
||||
//attributes values
|
||||
logrus.Debugf(" attribute name to compare : \"%s\"", r.GetAttributeValueAssertion().GetName())
|
||||
logrus.Debugf(" attribute value expected : \"%s\"", r.GetAttributeValueAssertion().GetValue())
|
||||
*/
|
||||
|
||||
res := ldapserver.NewCompareResponse(ldapserver.LDAPResultCompareTrue)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleAdd(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
/*
|
||||
r := m.GetAddRequest()
|
||||
logrus.Debugf("Adding entry: %s", r.GetEntryDN())
|
||||
//attributes values
|
||||
for _, attribute := range r.GetAttributes() {
|
||||
for _, attributeValue := range attribute.GetValues() {
|
||||
logrus.Debugf("- %s:%s", attribute.GetDescription(), attributeValue)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
res := ldapserver.NewAddResponse(ldapserver.LDAPResultSuccess)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleModify(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
/*
|
||||
r := m.GetModifyRequest()
|
||||
logrus.Debugf("Modify entry: %s", r.GetObject())
|
||||
|
||||
for _, change := range r.GetChanges() {
|
||||
modification := change.GetModification()
|
||||
var operationString string
|
||||
switch change.GetOperation() {
|
||||
case ldapserver.ModifyRequestChangeOperationAdd:
|
||||
operationString = "Add"
|
||||
case ldapserver.ModifyRequestChangeOperationDelete:
|
||||
operationString = "Delete"
|
||||
case ldapserver.ModifyRequestChangeOperationReplace:
|
||||
operationString = "Replace"
|
||||
}
|
||||
|
||||
|
||||
logrus.Debugf("%s attribute '%s'", operationString, modification.GetDescription())
|
||||
for _, attributeValue := range modification.GetValues() {
|
||||
logrus.Debugf("- value: %s", attributeValue)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
res := ldapserver.NewModifyResponse(ldapserver.LDAPResultSuccess)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleDelete(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
/*
|
||||
r := m.GetDeleteRequest()
|
||||
logrus.Debugf("Deleting entry: %s", r)
|
||||
*/
|
||||
res := ldapserver.NewDeleteResponse(ldapserver.LDAPResultSuccess)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleExtended(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
/*
|
||||
r := m.GetExtendedRequest()
|
||||
logrus.Debugf("Extended request received, name=%s", r.GetResponseName())
|
||||
logrus.Debugf("Extended request received, value=%x", r.GetResponseValue())
|
||||
*/
|
||||
res := ldapserver.NewExtendedResponse(ldapserver.LDAPResultSuccess)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleWhoAmI(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
res := ldapserver.NewExtendedResponse(ldapserver.LDAPResultSuccess)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleSearchDSE(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
r := m.GetSearchRequest()
|
||||
|
||||
attr := make([]string, 0)
|
||||
for _, v := range r.GetAttributes() {
|
||||
attr = append(attr, string(v))
|
||||
}
|
||||
|
||||
/*
|
||||
logrus.Debugf("Request BaseDn=%s", r.GetBaseObject())
|
||||
logrus.Debugf("Request Filter=%s", r.GetFilter())
|
||||
logrus.Debugf("Request Attributes=%s", strings.Join(attr, ","))
|
||||
logrus.Debugf("Request TimeLimit=%d", r.GetTimeLimit())
|
||||
*/
|
||||
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.AddAttribute("vendorName", "Test Vendor")
|
||||
e.AddAttribute("vendorVersion", "0.0.1")
|
||||
e.AddAttribute("objectClass", "top", "extensibleObject")
|
||||
e.AddAttribute("supportedLDAPVersion", "3")
|
||||
e.AddAttribute("namingContexts", "o=Test Company, c=US")
|
||||
w.Write(e)
|
||||
|
||||
res := ldapserver.NewSearchResultDoneResponse(ldapserver.LDAPResultSuccess)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleSearchMyCompany(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
r := m.GetSearchRequest()
|
||||
//logrus.Debugf("handleSearchMyCompany - Request BaseDn=%s", r.GetBaseObject())
|
||||
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.SetDn(string(r.GetBaseObject()))
|
||||
e.AddAttribute("objectClass", "top", "organizationalUnit")
|
||||
w.Write(e)
|
||||
|
||||
res := ldapserver.NewSearchResultDoneResponse(ldapserver.LDAPResultSuccess)
|
||||
w.Write(res)
|
||||
}
|
||||
|
||||
func handleSearch(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
r := m.GetSearchRequest()
|
||||
|
||||
if string(r.GetBaseObject()) == "" && r.GetScope() == ldapserver.SearchRequestScopeBaseObject && r.GetFilter() == "(objectclass=*)" {
|
||||
handleSearchDSE(w, m)
|
||||
return
|
||||
}
|
||||
|
||||
if string(r.GetBaseObject()) == "o=My Company, c=US" && r.GetScope() == ldapserver.SearchRequestScopeBaseObject {
|
||||
handleSearchMyCompany(w, m)
|
||||
return
|
||||
}
|
||||
|
||||
attr := make([]string, 0)
|
||||
for _, v := range r.GetAttributes() {
|
||||
attr = append(attr, string(v))
|
||||
}
|
||||
|
||||
/*
|
||||
logrus.Debugf("Request BaseDn=%s", string(r.GetBaseObject()))
|
||||
logrus.Debugf("Request Filter=%s", r.GetFilter())
|
||||
logrus.Debugf("Request Attributes=%s", strings.Join(attr, ","))
|
||||
logrus.Debugf("Request TimeLimit=%d", r.GetTimeLimit())
|
||||
*/
|
||||
|
||||
// Handle Stop Signal (server stop / client disconnected / Abandoned request....)
|
||||
select {
|
||||
case <-m.Done:
|
||||
//logrus.Info("Leaving handleSearch...")
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
if r.GetFilter() == "(uid=Test1)" {
|
||||
//logrus.Debugf("Prepare Result Test1 for %s", r.GetFilter())
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.SetDn("uid=Test1," + string(r.GetBaseObject()))
|
||||
e.AddAttribute("mail", "test.ldap@example.com", "testldap@example.com")
|
||||
e.AddAttribute("uid", "Test1")
|
||||
e.AddAttribute("cn", "Test1")
|
||||
e.AddAttribute("ou", "People")
|
||||
e.AddAttribute("dc", "example", "com")
|
||||
e.AddAttribute("memberOf", "cn=Test - Group1,dc=example,dc=com", "cn=Test - Group2,dc=example,dc=com", "cn=Test - Group3,dc=example,dc=com")
|
||||
w.Write(e)
|
||||
}
|
||||
|
||||
if r.GetFilter() == "(uid=Test2)" {
|
||||
//logrus.Debugf("Prepare Result Test2 for %s", r.GetFilter())
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.SetDn("uid=Test2," + string(r.GetBaseObject()))
|
||||
e.AddAttribute("mail", "test.2.ldap@example.com")
|
||||
e.AddAttribute("uid", "Test2")
|
||||
e.AddAttribute("cn", "Test2")
|
||||
e.AddAttribute("ou", "People")
|
||||
e.AddAttribute("dc", "example", "com")
|
||||
e.AddAttribute("memberOf", "cn=Test - Group1,dc=example,dc=com", "cn=Test - Group2,dc=example,dc=com")
|
||||
w.Write(e)
|
||||
}
|
||||
|
||||
if r.GetFilter() == "(uid=Test3)" {
|
||||
//logrus.Debugf("Prepare Result Test3 for %s", r.GetFilter())
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.SetDn("uid=Test3," + string(r.GetBaseObject()))
|
||||
e.AddAttribute("mail", "test.3.ldap@example.com")
|
||||
e.AddAttribute("uid", "Test3")
|
||||
e.AddAttribute("cn", "Test3")
|
||||
e.AddAttribute("ou", "People")
|
||||
e.AddAttribute("dc", "example", "com")
|
||||
e.AddAttribute("memberOf", "cn=Test - Group1,dc=example,dc=com", "cn=Test - Group3,dc=example,dc=com")
|
||||
w.Write(e)
|
||||
}
|
||||
|
||||
if r.GetFilter() == "(&(objectClass=groupOfNames)(cn=Test - Group1))" {
|
||||
//logrus.Debugf("Prepare Result [Test - Group1] for %s", r.GetFilter())
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.SetDn("uid=Test - Group1," + string(r.GetBaseObject()))
|
||||
e.AddAttribute("cn", "Test - Group1")
|
||||
e.AddAttribute("ou", "Group")
|
||||
e.AddAttribute("dc", "example", "com")
|
||||
e.AddAttribute("member", "uid=Test1,dc=example,dc=com", "uid=Test2,dc=example,dc=com", "uid=Test3,dc=example,dc=com")
|
||||
w.Write(e)
|
||||
}
|
||||
|
||||
if r.GetFilter() == "(&(objectClass=groupOfNames)(cn=Test - Group2))" {
|
||||
//logrus.Debugf("Prepare Result [Test - Group2] for %s", r.GetFilter())
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.SetDn("uid=Test - Group2," + string(r.GetBaseObject()))
|
||||
e.AddAttribute("cn", "Test - Group2")
|
||||
e.AddAttribute("ou", "Group")
|
||||
e.AddAttribute("dc", "example", "com")
|
||||
e.AddAttribute("member", "uid=Test1,dc=example,dc=com", "uid=Test3,dc=example,dc=com")
|
||||
w.Write(e)
|
||||
}
|
||||
|
||||
if r.GetFilter() == "(&(objectClass=groupOfNames)(cn=Test - Group3))" {
|
||||
//logrus.Debugf("Prepare Result [Test - Group3] for %s", r.GetFilter())
|
||||
e := ldapserver.NewSearchResultEntry()
|
||||
e.SetDn("uid=Test - Group3," + string(r.GetBaseObject()))
|
||||
e.AddAttribute("cn", "Test - Group3")
|
||||
e.AddAttribute("ou", "Group")
|
||||
e.AddAttribute("dc", "example", "com")
|
||||
e.AddAttribute("member", "uid=Test1,dc=example,dc=com", "uid=Test2,dc=example,dc=com")
|
||||
w.Write(e)
|
||||
}
|
||||
|
||||
res := ldapserver.NewSearchResultDoneResponse(ldapserver.LDAPResultSuccess)
|
||||
|
||||
//logrus.Debugf("Res Found : %v", res)
|
||||
w.Write(res)
|
||||
|
||||
}
|
||||
|
||||
// localhostCert is a PEM-encoded TLS cert with SAN DNS names
|
||||
// "127.0.0.1" and "[::1]", expiring at the last second of 2049 (the end
|
||||
// of ASN.1 time).
|
||||
var localhostCert = []byte(`-----BEGIN CERTIFICATE-----
|
||||
MIIBOTCB5qADAgECAgEAMAsGCSqGSIb3DQEBBTAAMB4XDTcwMDEwMTAwMDAwMFoX
|
||||
DTQ5MTIzMTIzNTk1OVowADBaMAsGCSqGSIb3DQEBAQNLADBIAkEAsuA5mAFMj6Q7
|
||||
qoBzcvKzIq4kzuT5epSp2AkcQfyBHm7K13Ws7u+0b5Vb9gqTf5cAiIKcrtrXVqkL
|
||||
8i1UQF6AzwIDAQABo08wTTAOBgNVHQ8BAf8EBAMCACQwDQYDVR0OBAYEBAECAwQw
|
||||
DwYDVR0jBAgwBoAEAQIDBDAbBgNVHREEFDASggkxMjcuMC4wLjGCBVs6OjFdMAsG
|
||||
CSqGSIb3DQEBBQNBAJH30zjLWRztrWpOCgJL8RQWLaKzhK79pVhAx6q/3NrF16C7
|
||||
+l1BRZstTwIGdoGId8BRpErK1TXkniFb95ZMynM=
|
||||
-----END CERTIFICATE-----
|
||||
`)
|
||||
|
||||
// localhostKey is the private key for localhostCert.
|
||||
var localhostKey = []byte(`-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIBPQIBAAJBALLgOZgBTI+kO6qAc3LysyKuJM7k+XqUqdgJHEH8gR5uytd1rO7v
|
||||
tG+VW/YKk3+XAIiCnK7a11apC/ItVEBegM8CAwEAAQJBAI5sxq7naeR9ahyqRkJi
|
||||
SIv2iMxLuPEHaezf5CYOPWjSjBPyVhyRevkhtqEjF/WkgL7C2nWpYHsUcBDBQVF0
|
||||
3KECIQDtEGB2ulnkZAahl3WuJziXGLB+p8Wgx7wzSM6bHu1c6QIhAMEp++CaS+SJ
|
||||
/TrU0zwY/fW4SvQeb49BPZUF3oqR8Xz3AiEA1rAJHBzBgdOQKdE3ksMUPcnvNJSN
|
||||
poCcELmz2clVXtkCIQCLytuLV38XHToTipR4yMl6O+6arzAjZ56uq7m7ZRV0TwIh
|
||||
AM65XAOw8Dsg9Kq78aYXiOEDc5DL0sbFUu/SlmRcCg93
|
||||
-----END RSA PRIVATE KEY-----
|
||||
`)
|
||||
|
||||
// getTLSconfig returns a tls configuration used
|
||||
// to build a TLSlistener for TLS or StartTLS
|
||||
func getTLSconfig() (*tls.Config, error) {
|
||||
cert, err := tls.X509KeyPair(localhostCert, localhostKey)
|
||||
if err != nil {
|
||||
return &tls.Config{}, err
|
||||
}
|
||||
|
||||
return &tls.Config{
|
||||
MinVersion: tls.VersionTLS12,
|
||||
MaxVersion: tls.VersionTLS12,
|
||||
Certificates: []tls.Certificate{cert},
|
||||
ServerName: "127.0.0.1",
|
||||
}, nil
|
||||
}
|
||||
|
||||
func handleStartTLS(w ldapserver.ResponseWriter, m *ldapserver.Message) {
|
||||
tlsconfig, e := getTLSconfig()
|
||||
if e != nil {
|
||||
logrus.Errorf("error while retrieve TLS config: %v", e)
|
||||
}
|
||||
|
||||
tlsConn := tls.Server(m.Client.GetConn(), tlsconfig)
|
||||
res := ldapserver.NewExtendedResponse(ldapserver.LDAPResultSuccess)
|
||||
res.ResponseName = ldapserver.NoticeOfStartTLS
|
||||
w.Write(res)
|
||||
|
||||
if err := tlsConn.Handshake(); err != nil {
|
||||
logrus.Errorf("StartTLS Handshake error %v", err)
|
||||
res.DiagnosticMessage = fmt.Sprintf("StartTLS Handshake error : \"%s\"", err.Error())
|
||||
res.ResultCode = ldapserver.LDAPResultOperationsError
|
||||
w.Write(res)
|
||||
return
|
||||
}
|
||||
|
||||
m.Client.SetConn(tlsConn)
|
||||
logrus.Info("StartTLS OK")
|
||||
}
|
||||
BIN
njs-ldap/obsolete.tgz
Normal file
BIN
njs-ldap/obsolete.tgz
Normal file
Binary file not shown.
12
update_dep
Executable file
12
update_dep
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
go clean -r -x -cache -testcache -modcache
|
||||
if [[ ! -e go.mod ]] ;
|
||||
then
|
||||
go mod init
|
||||
go get ./...
|
||||
fi
|
||||
|
||||
go mod download
|
||||
go mod vendor
|
||||
|
||||
go get -u ./... && go mod download && go mod vendor
|
||||
Reference in New Issue
Block a user