Skip to content

Commit 5f4965c

Browse files
committed
Update Dependencies
1 parent 80805e2 commit 5f4965c

8 files changed

+96
-58
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.vscode
2-
.DS_Store
2+
.DS_Store
3+
.env
4+
conf/

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "mosquitto-go-auth"]
2+
path = mosquitto-go-auth
3+
url = https://github.com/iegomez/mosquitto-go-auth.git

Dockerfile

+49-21
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,80 @@
1-
#Set mosquitto and plugin versions.
1+
#Set mosquitto, golang and libwebsocket versions.
22
#Change them as per your needs.
3-
ARG MOSQUITTO_VERSION=2.0.12
4-
ARG PLUGIN_VERSION=1.8.2
5-
ARG GOLANG_VERSION=1.17.5
3+
ARG MOSQUITTO_VERSION=2.0.18
4+
ARG GOLANG_VERSION=1.22.4
5+
ARG LWS_VERSION=4.2.2
66

77
#Use debian:stable-slim as a builder and then copy everything.
88
FROM debian:stable-slim as builder
9+
910
ARG MOSQUITTO_VERSION
11+
ARG LWS_VERSION
12+
13+
RUN set -ex; \
14+
apt-get update; \
15+
apt-get install -y wget build-essential cmake libssl-dev libcjson-dev
16+
17+
# Get libwebsocket. Debian's libwebsockets is too old for Mosquitto version > 2.x so it gets built from source.
18+
RUN set -ex; \
19+
wget https://github.com/warmcat/libwebsockets/archive/v${LWS_VERSION}.tar.gz -O /tmp/lws.tar.gz; \
20+
mkdir -p /build/lws; \
21+
tar --strip=1 -xf /tmp/lws.tar.gz -C /build/lws; \
22+
rm /tmp/lws.tar.gz; \
23+
cd /build/lws; \
24+
cmake . \
25+
-DCMAKE_BUILD_TYPE=MinSizeRel \
26+
-DCMAKE_INSTALL_PREFIX=/usr \
27+
-DLWS_IPV6=ON \
28+
-DLWS_WITHOUT_BUILTIN_GETIFADDRS=ON \
29+
-DLWS_WITHOUT_CLIENT=ON \
30+
-DLWS_WITHOUT_EXTENSIONS=ON \
31+
-DLWS_WITHOUT_TESTAPPS=ON \
32+
-DLWS_WITH_HTTP2=OFF \
33+
-DLWS_WITH_SHARED=OFF \
34+
-DLWS_WITH_ZIP_FOPS=OFF \
35+
-DLWS_WITH_ZLIB=OFF \
36+
-DLWS_WITH_EXTERNAL_POLL=ON; \
37+
make -j "$(nproc)"; \
38+
rm -rf /root/.cmake
1039

1140
WORKDIR /app
1241

13-
#Get mosquitto build dependencies.
14-
RUN apt update && apt install -y wget build-essential cmake libssl-dev libcjson-dev libwebsockets-dev
1542
RUN mkdir -p mosquitto/auth mosquitto/conf.d
1643

1744
RUN wget http://mosquitto.org/files/source/mosquitto-${MOSQUITTO_VERSION}.tar.gz
18-
RUN tar xzvf mosquitto-${MOSQUITTO_VERSION}.tar.gz && rm mosquitto-${MOSQUITTO_VERSION}.tar.gz
1945

20-
#Build mosquitto.
21-
RUN cd mosquitto-${MOSQUITTO_VERSION} && make CFLAGS="-Wall -O2 -I/build/lws/include" LDFLAGS="-L/build/lws/lib" WITH_WEBSOCKETS=yes && make install && cd ..
46+
RUN tar xzvf mosquitto-${MOSQUITTO_VERSION}.tar.gz
47+
48+
# Build mosquitto.
49+
RUN set -ex; \
50+
cd mosquitto-${MOSQUITTO_VERSION}; \
51+
make CFLAGS="-Wall -O2 -I/build/lws/include" LDFLAGS="-L/build/lws/lib" WITH_WEBSOCKETS=yes; \
52+
make install;
2253

2354
# Use golang:latest as a builder for the Mosquitto Go Auth plugin.
2455
FROM golang:${GOLANG_VERSION} AS go_auth_builder
2556

26-
ARG PLUGIN_VERSION
57+
# ARG PLUGIN_VERSION
2758
ENV CGO_CFLAGS="-I/usr/local/include -fPIC"
2859
ENV CGO_LDFLAGS="-shared -Wl,-unresolved-symbols=ignore-all"
2960
ENV CGO_ENABLED=1
3061

3162
# Install TARGETPLATFORM parser to translate its value to GOOS, GOARCH, and GOARM
3263
COPY --from=tonistiigi/xx:golang / /
64+
RUN go env
3365

3466
RUN apt update && apt install -y gcc-aarch64-linux-gnu libc6-dev-arm64-cross
3567

3668
WORKDIR /app
3769
COPY --from=builder /usr/local/include/ /usr/local/include/
3870

39-
#Get the plugin.
40-
RUN wget https://github.com/iegomez/mosquitto-go-auth/archive/refs/tags/${PLUGIN_VERSION}.tar.gz \
41-
&& ls -l \
42-
&& tar xvf *.tar.gz --strip-components=1 \
43-
&& rm -Rf go*.tar.gz \
44-
&& ls -l
45-
46-
#Build the plugin.
47-
RUN go build -buildmode=c-archive go-auth.go && \
48-
go build -buildmode=c-shared -o go-auth.so && \
49-
go build pw-gen/pw.go
71+
COPY ./mosquitto-go-auth /app
72+
73+
#Build the basic auth plugin.
74+
RUN set -ex; \
75+
go build -buildmode=c-archive go-auth.go; \
76+
go build -buildmode=c-shared -o go-auth.so; \
77+
go build pw-gen/pw.go
5078

5179
#Get the oauth plugin
5280
RUN go mod download golang.org/x/oauth2

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Mosquitto Go Auth Plugin for OAuth2
22

33
This is a custom backend for the [mosquitto go auth plugin](https://github.com/iegomez/mosquitto-go-auth) that can handle the authentication and authorization with a oauth2 server.
4+
- It is necessary to check the respective versions of Go and the dependencies
45

56
## How to use
67

@@ -36,4 +37,6 @@ Configuration options are listed below:
3637
## How to test
3738

3839
The simplest way is to use the delivered dockerfile and build your own image. You can use volumes to import the configurations or copy the files in the images while you build it.
39-
If you use volumes you have to remove the `COPY` commands from the Dockerfile.
40+
If you use volumes you have to remove the `COPY` commands from the Dockerfile.
41+
42+
You can use the attached [docker-compose.yml](docker-compose.yml) for deployment.

docker-compose.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
services:
2+
mosquitto_oauth2:
3+
restart: unless-stopped
4+
image: gewvtudresden/mosquitto-go-auth-oauth2:${TAG}
5+
hostname: mosquitto_oauth2
6+
container_name: mosquitto_oauth2
7+
logging:
8+
options:
9+
max-size: "10m"
10+
max-file: "3"
11+
ports:
12+
- ${PORT}:1883
13+
volumes:
14+
- ./example_conf:/etc/mosquitto

mosquitto-go-auth

Submodule mosquitto-go-auth added at 5968118

src/go.mod

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
module mosquitto-go-auth-oauth2
22

3-
go 1.13
3+
go 1.22
44

55
require (
6-
github.com/golang/protobuf v1.3.1 // indirect
7-
github.com/sirupsen/logrus v1.6.0
8-
github.com/stretchr/testify v1.3.0 // indirect
9-
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c // indirect
10-
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
11-
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 // indirect
12-
google.golang.org/appengine v1.5.0 // indirect
6+
github.com/sirupsen/logrus v1.9.3
7+
golang.org/x/oauth2 v0.21.0
8+
)
9+
10+
require (
11+
github.com/google/go-cmp v0.6.0 // indirect
12+
golang.org/x/sys v0.21.0 // indirect
1313
)

src/go.sum

+14-27
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,20 @@
1-
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
21
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
32
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
43
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5-
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
6-
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
7-
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
8-
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
9-
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
4+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
5+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
106
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
117
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
12-
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
13-
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
8+
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
9+
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
1410
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
15-
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
16-
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
17-
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
18-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
19-
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
20-
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
21-
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c h1:uOCk1iQW6Vc18bnC13MfzScl+wdKBmM9Y9kU7Z83/lw=
22-
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
23-
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
24-
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
25-
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
26-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
27-
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
28-
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7NkNAQs+6Q8b9WEB/F4=
29-
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
30-
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
31-
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
32-
google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c=
33-
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
11+
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
12+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
13+
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
14+
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
15+
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
16+
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
17+
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
18+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
19+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
20+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)