Skip to content

Commit f632bec

Browse files
committed
merge conflicts resolved
2 parents 698a4be + f35429f commit f632bec

File tree

123 files changed

+5080
-779
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+5080
-779
lines changed

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ body:
3131
label: Version
3232
description: What version are you running?
3333
options:
34-
- v0.15.1
34+
- v0.16.0
35+
- v0.15.2
36+
- v0.15.1
3537
- v0.15.0
3638
- v0.14.6
3739
- v0.14.5

.github/workflows/buildandrelease.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ jobs:
402402
cd netclient
403403
env GOOS=darwin GOARCH=amd64 go build -tags=gui -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-darwin/netclient .
404404
env CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -tags=gui -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-darwin-arm64/netclient main.go
405+
env GOOS=darwin GOARCH=amd64 go build -ldflags="-X 'main.version=${NETMAKER_VERSION}'" -o build/netclient-darwin-headless/netclient .
405406
- name: Upload darwin-amd64 to Release
406407
uses: svenstaro/upload-release-action@v2
407408
with:
@@ -421,7 +422,17 @@ jobs:
421422
overwrite: true
422423
prerelease: true
423424
asset_name: netclient-darwin-arm64
424-
425+
426+
- name: Upload darwin-headless to Release
427+
uses: svenstaro/upload-release-action@v2
428+
with:
429+
repo_token: ${{ secrets.GITHUB_TOKEN }}
430+
file: netclient/build/netclient-darwin-headless/netclient
431+
tag: ${{ env.NETMAKER_VERSION }}
432+
overwrite: true
433+
prerelease: true
434+
asset_name: netclient-darwin-headless
435+
425436
netclient-windows:
426437
runs-on: windows-latest
427438
needs: version

.github/workflows/docker-builder.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ jobs:
2323
with:
2424
context: .
2525
push: true
26-
platforms: linux/amd64, linux/arm64
26+
platforms: linux/amd64, linux/arm64, linux/armv7l
2727
file: ./docker/Dockerfile-go-builder
2828
tags: gravitl/go-builder:latest

.github/workflows/publish-docker.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
sleep 10
5656
kill %1
5757
-
58-
name: Build arm and export to Docker
58+
name: Build arm64 and export to Docker
5959
uses: docker/build-push-action@v2
6060
with:
6161
context: .
@@ -64,7 +64,22 @@ jobs:
6464
tags: ${{ env.TAG }}
6565
build-args: version=${{ env.TAG }}
6666
-
67-
name: Test arm
67+
name: Test arm64
68+
run: |
69+
docker run --rm ${{ env.TAG }}&
70+
sleep 10
71+
kill %1
72+
-
73+
name: Build armv7l and export to Docker
74+
uses: docker/build-push-action@v2
75+
with:
76+
context: .
77+
load: true
78+
platforms: linux/armv7l
79+
tags: ${{ env.TAG }}
80+
build-args: version=${{ env.TAG }}
81+
-
82+
name: Test armv7l
6883
run: |
6984
docker run --rm ${{ env.TAG }}&
7085
sleep 10
@@ -74,7 +89,7 @@ jobs:
7489
uses: docker/build-push-action@v2
7590
with:
7691
context: .
77-
platforms: linux/amd64, linux/arm64
92+
platforms: linux/amd64, linux/arm64, linux/armv7l
7893
push: true
7994
tags: ${{ github.repository }}:${{ env.TAG }}, ${{ github.repository }}:latest
8095
build-args: version=${{ env.TAG }}

.github/workflows/publish-netclient-docker.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
sleep 10
5757
kill %1
5858
-
59-
name: Build arm and export to Docker
59+
name: Build arm64 and export to Docker
6060
uses: docker/build-push-action@v2
6161
with:
6262
context: .
@@ -66,7 +66,23 @@ jobs:
6666
tags: ${{ env.TAG }}
6767
build-args: version=${{ env.TAG }}
6868
-
69-
name: Test arm
69+
name: Test arm64
70+
run: |
71+
docker run --rm ${{ env.TAG }}&
72+
sleep 10
73+
kill %1
74+
-
75+
name: Build armv7l and export to Docker
76+
uses: docker/build-push-action@v2
77+
with:
78+
context: .
79+
load: true
80+
platforms: linux/armv7l
81+
file: ./docker/Dockerfile-netclient-multiarch
82+
tags: ${{ env.TAG }}
83+
build-args: version=${{ env.TAG }}
84+
-
85+
name: Test armv7l
7086
run: |
7187
docker run --rm ${{ env.TAG }}&
7288
sleep 10
@@ -76,7 +92,7 @@ jobs:
7692
uses: docker/build-push-action@v2
7793
with:
7894
context: .
79-
platforms: linux/amd64, linux/arm64
95+
platforms: linux/amd64, linux/arm64, linux/armv7l
8096
file: ./docker/Dockerfile-netclient-multiarch
8197
push: true
8298
tags: gravitl/netclient:${{ env.TAG }}, gravitl/netclient:latest

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
- name: Build
1818
run: |
1919
env CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build main.go
20+
env CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -tags=ee main.go
2021
cd netclient
2122
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go
2223
env CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build main.go
@@ -81,7 +82,7 @@ jobs:
8182
sudo apt-get install -y gcc libgl1-mesa-dev xorg-dev
8283
go test -p 1 ./... -v
8384
go install honnef.co/go/tools/cmd/staticcheck@latest
84-
~/go/bin/staticcheck ./...
85+
{ ~/go/bin/staticcheck -tags=ee ./... ; }
8586
env:
8687
DATABASE: sqlite
8788
CLIENT_MODE: "off"

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#first stage - builder
22
FROM gravitl/go-builder as builder
3-
ARG version
3+
ARG version
4+
ARG tags
45
WORKDIR /app
56
COPY . .
67
ENV GO111MODULE=auto
78

8-
RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -X 'main.version=${version}'" -o netmaker main.go
9+
RUN apk add git
10+
RUN GOOS=linux CGO_ENABLED=1 go build ${tags} -ldflags="-s -X 'main.version=${version}'" .
11+
# RUN go build -tags=ee . -o netmaker main.go
912
FROM alpine:3.15.2
1013

1114
# add a c lib

Dockerfile-quick

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#first stage - builder
2+
FROM alpine:3.15.2
3+
ARG version
4+
WORKDIR /app
5+
COPY ./netmaker /root/netmaker
6+
ENV GO111MODULE=auto
7+
8+
# add a c lib
9+
RUN apk add gcompat iptables wireguard-tools
10+
# set the working directory
11+
WORKDIR /root/
12+
RUN mkdir -p /etc/netclient/config
13+
EXPOSE 8081
14+
ENTRYPOINT ["./netmaker"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<p align="center">
1919
<a href="https://github.com/gravitl/netmaker/releases">
20-
<img src="https://img.shields.io/badge/Version-0.15.1-informational?style=flat-square" />
20+
<img src="https://img.shields.io/badge/Version-0.16.0-informational?style=flat-square" />
2121
</a>
2222
<a href="https://hub.docker.com/r/gravitl/netmaker/tags">
2323
<img src="https://img.shields.io/docker/pulls/gravitl/netmaker?label=downloads" />

auth/auth.go

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/gravitl/netmaker/logger"
1111
"github.com/gravitl/netmaker/logic"
12+
"github.com/gravitl/netmaker/logic/pro/netcache"
1213
"github.com/gravitl/netmaker/models"
1314
"github.com/gravitl/netmaker/servercfg"
1415
"golang.org/x/crypto/bcrypt"
@@ -27,8 +28,19 @@ const (
2728
oidc_provider_name = "oidc"
2829
verify_user = "verifyuser"
2930
auth_key = "netmaker_auth"
31+
user_signin_length = 16
32+
node_signin_length = 64
3033
)
3134

35+
// OAuthUser - generic OAuth strategy user
36+
type OAuthUser struct {
37+
Name string `json:"name" bson:"name"`
38+
Email string `json:"email" bson:"email"`
39+
Login string `json:"login" bson:"login"`
40+
UserPrincipalName string `json:"userPrincipalName" bson:"userPrincipalName"`
41+
AccessToken string `json:"accesstoken" bson:"accesstoken"`
42+
}
43+
3244
var auth_provider *oauth2.Config
3345

3446
func getCurrentAuthFunctions() map[string]interface{} {
@@ -94,7 +106,14 @@ func HandleAuthCallback(w http.ResponseWriter, r *http.Request) {
94106
if functions == nil {
95107
return
96108
}
97-
functions[handle_callback].(func(http.ResponseWriter, *http.Request))(w, r)
109+
state, _ := getStateAndCode(r)
110+
_, err := netcache.Get(state) // if in netcache proceeed with node registration login
111+
if err == nil || len(state) == node_signin_length || (err != nil && strings.Contains(err.Error(), "expired")) {
112+
logger.Log(0, "proceeding with node SSO callback")
113+
HandleNodeSSOCallback(w, r)
114+
} else { // handle normal login
115+
functions[handle_callback].(func(http.ResponseWriter, *http.Request))(w, r)
116+
}
98117
}
99118

100119
// swagger:route GET /api/oauth/login nodes HandleAuthLogin
@@ -197,3 +216,35 @@ func fetchPassValue(newValue string) (string, error) {
197216
}
198217
return string(b64CurrentValue), nil
199218
}
219+
220+
func getStateAndCode(r *http.Request) (string, string) {
221+
var state, code string
222+
if r.FormValue("state") != "" && r.FormValue("code") != "" {
223+
state = r.FormValue("state")
224+
code = r.FormValue("code")
225+
} else if r.URL.Query().Get("state") != "" && r.URL.Query().Get("code") != "" {
226+
state = r.URL.Query().Get("state")
227+
code = r.URL.Query().Get("code")
228+
}
229+
230+
return state, code
231+
}
232+
233+
func (user *OAuthUser) getUserName() string {
234+
var userName string
235+
if user.Email != "" {
236+
userName = user.Email
237+
} else if user.Login != "" {
238+
userName = user.Login
239+
} else if user.UserPrincipalName != "" {
240+
userName = user.UserPrincipalName
241+
} else if user.Name != "" {
242+
userName = user.Name
243+
}
244+
return userName
245+
}
246+
247+
func isStateCached(state string) bool {
248+
_, err := netcache.Get(state)
249+
return err == nil || strings.Contains(err.Error(), "expired")
250+
}

0 commit comments

Comments
 (0)