Skip to content

Commit

Permalink
Remove incomplete strict mode vars.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ignacio Gómez committed Dec 12, 2018
1 parent 93d73db commit 6b8046b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ It was intended for use with [brocaar's](https://github.com/brocaar) [Loraserver
* Files
* PostgreSQL
* JWT (with local DB or remote API)
* HTTP (added)
* Redis (added)
* Mysql (added)
* SQLite3 (added)
* MongoDB (added)
* HTTP
* Redis
* Mysql
* SQLite3
* MongoDB
* Custom (experimental)

**Every backend offers user, superuser and acl checks, and include proper tests.**
Expand Down Expand Up @@ -75,9 +75,7 @@ The plugin was developed because I needed a JWT local mode and it was faster to

### Requirements

This projects was created with Go 1.9.2 (developing with 1.10 right now) and makes use of cgo. It probably works fine with Go 1.8 too, but I haven't tested it yet (any results are welcome).

It makes use of some Go packages as well, which are managed with dep (install it with `make dev-requirements` if you don't have it already). Run this to have dep install the dependencies:
This is tested against Go 1.10.3 and makes use of cgo. It depends on some Go packages as well, which are managed with dep (install it with `make dev-requirements` if you don't have it already). Run this to have dep install the dependencies:

```
make requirements
Expand All @@ -94,7 +92,7 @@ First, install dependencies (tested on Debian 9):

`sudo apt-get install libwebsockets8 libwebsockets-dev libc-ares2 libc-ares-dev openssl uuid uuid-dev`

Download mosquitto and extract it (change versions accordingly):
Download mosquitto and extract it (**change versions accordingly**):

```
wget https://mosquitto.org/files/source/mosquitto-1.4.15.tar.gz
Expand Down
21 changes: 4 additions & 17 deletions go-auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type CommonData struct {
CheckPrefix bool
Prefixes map[string]string
LogLevel log.Level
StrictMode bool
}

//Cache stores necessary values for Redis cache
Expand All @@ -66,11 +65,10 @@ var allowedBackends = map[string]bool{
"plugin": true,
}

var backends []string //List of selected backends.
var authOpts map[string]string //Options passed by mosquitto.
var cache Cache //Cache conf.
var commonData CommonData //General struct with options and conf.
var strictMap map[string]string //Maps users to backends by name.
var backends []string //List of selected backends.
var authOpts map[string]string //Options passed by mosquitto.
var cache Cache //Cache conf.
var commonData CommonData //General struct with options and conf.

//export AuthPluginInit
func AuthPluginInit(keys []string, values []string, authOptsNum int) {
Expand Down Expand Up @@ -148,15 +146,6 @@ func AuthPluginInit(keys []string, values []string, authOptsNum int) {

}

//Check if strict mode is set.
if strictMode, ok := authOpts["strict_mode"]; ok && strings.Replace(strictMode, " ", "", -1) == "true" {
log.Info("Strict mode set.")
commonData.StrictMode = true
} else {
log.Info("Non strict mode set.")
commonData.StrictMode = false
}

//Initialize backends
for _, bename := range backends {
var beIface Backend
Expand Down Expand Up @@ -425,8 +414,6 @@ func AuthPluginInit(keys []string, values []string, authOptsNum int) {
//export AuthUnpwdCheck
func AuthUnpwdCheck(username, password string) bool {

//Loop through backends checking for user if we are on non strict mode or the user hasn't been seen yet.

authenticated := false
var cached = false
var granted = false
Expand Down

0 comments on commit 6b8046b

Please sign in to comment.