Skip to content

Commit

Permalink
Merge pull request #2563 from gravitl/release-v0.21.0
Browse files Browse the repository at this point in the history
v0.21.0
  • Loading branch information
abhishek9686 authored Sep 12, 2023
2 parents 6937134 + 868b531 commit f158caf
Show file tree
Hide file tree
Showing 111 changed files with 1,655 additions and 3,463 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ body:
label: Version
description: What version are you running?
options:
- v0.21.0
- v0.20.6
- v0.20.5
- v0.20.4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
build-args: |
tags=ce
docker-ee:
docker-pro:
runs-on: ubuntu-latest
steps:
-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
run: |
go vet ./...
go test -p 1 ./... -v
go test -p 1 ./ee -v --tags ee
go test -p 1 ./pro -v --tags ee
env:
DATABASE: sqlite
CLIENT_MODE: "off"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<p align="center">
<a href="https://github.com/gravitl/netmaker/releases">
<img src="https://img.shields.io/badge/Version-0.20.6-informational?style=flat-square" />
<img src="https://img.shields.io/badge/Version-0.21.0-informational?style=flat-square" />
</a>
<a href="https://hub.docker.com/r/gravitl/netmaker/tags">
<img src="https://img.shields.io/docker/pulls/gravitl/netmaker?label=downloads" />
Expand Down
13 changes: 7 additions & 6 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"golang.org/x/crypto/bcrypt"
"golang.org/x/exp/slog"
"golang.org/x/oauth2"

"github.com/gorilla/websocket"
Expand Down Expand Up @@ -238,9 +239,9 @@ func HandleHeadlessSSO(w http.ResponseWriter, r *http.Request) {
// == private methods ==

func addUser(email string) error {
var hasAdmin, err = logic.HasAdmin()
var hasSuperAdmin, err = logic.HasSuperAdmin()
if err != nil {
logger.Log(1, "error checking for existence of admin user during OAuth login for", email, "; user not added")
slog.Error("error checking for existence of admin user during OAuth login for", "email", email, "error", err)
return err
} // generate random password to adapt to current model
var newPass, fetchErr = fetchPassValue("")
Expand All @@ -251,11 +252,11 @@ func addUser(email string) error {
UserName: email,
Password: newPass,
}
if !hasAdmin { // must be first attempt, create an admin
if err = logic.CreateAdmin(&newUser); err != nil {
logger.Log(1, "error creating admin from user,", email, "; user not added")
if !hasSuperAdmin { // must be first attempt, create a superadmin
if err = logic.CreateSuperAdmin(&newUser); err != nil {
slog.Error("error creating super admin from user", "email", email, "error", err)
} else {
logger.Log(1, "admin created from user,", email, "; was first user added")
slog.Info("superadmin created from user", "email", email)
}
} else { // otherwise add to db as admin..?
// TODO: add ability to add users with preemptive permissions
Expand Down
22 changes: 0 additions & 22 deletions auth/register_callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import (
"github.com/gorilla/mux"
"github.com/gravitl/netmaker/logger"
"github.com/gravitl/netmaker/logic"
"github.com/gravitl/netmaker/logic/pro"
"github.com/gravitl/netmaker/logic/pro/netcache"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/models/promodels"
)

var (
Expand Down Expand Up @@ -165,25 +163,5 @@ func isUserIsAllowed(username, network string, shouldAddUser bool) (*models.User
user, _ = logic.GetUser(username)
}

if !user.IsAdmin { // perform check to see if user is allowed to join a node to network
netUser, err := pro.GetNetworkUser(network, promodels.NetworkUserID(user.UserName))
if err != nil {
logger.Log(0, "failed to get net user details for user", user.UserName, "during node SSO")
return nil, fmt.Errorf("failed to verify network user")
}
if netUser.AccessLevel != pro.NET_ADMIN { // if user is a net admin on network, good to go
// otherwise, check if they have node access + haven't reached node limit on network
if netUser.AccessLevel == pro.NODE_ACCESS {
if len(netUser.Nodes) >= netUser.NodeLimit {
logger.Log(0, "user", user.UserName, "has reached their node limit on network", network)
return nil, fmt.Errorf("user node limit exceeded")
}
} else {
logger.Log(0, "user", user.UserName, "attempted to access network", network, "via node SSO")
return nil, fmt.Errorf("network user not allowed")
}
}
}

return user, nil
}
43 changes: 0 additions & 43 deletions cli/cmd/network_user/create.go

This file was deleted.

23 changes: 0 additions & 23 deletions cli/cmd/network_user/delete.go

This file was deleted.

10 changes: 0 additions & 10 deletions cli/cmd/network_user/flags.go

This file was deleted.

27 changes: 0 additions & 27 deletions cli/cmd/network_user/get.go

This file was deleted.

27 changes: 0 additions & 27 deletions cli/cmd/network_user/list.go

This file was deleted.

28 changes: 0 additions & 28 deletions cli/cmd/network_user/root.go

This file was deleted.

43 changes: 0 additions & 43 deletions cli/cmd/network_user/update.go

This file was deleted.

4 changes: 0 additions & 4 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ import (
"github.com/gravitl/netmaker/cli/cmd/host"
"github.com/gravitl/netmaker/cli/cmd/metrics"
"github.com/gravitl/netmaker/cli/cmd/network"
"github.com/gravitl/netmaker/cli/cmd/network_user"
"github.com/gravitl/netmaker/cli/cmd/node"
"github.com/gravitl/netmaker/cli/cmd/server"
"github.com/gravitl/netmaker/cli/cmd/user"
"github.com/gravitl/netmaker/cli/cmd/usergroup"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -52,9 +50,7 @@ func init() {
rootCmd.AddCommand(server.GetRoot())
rootCmd.AddCommand(ext_client.GetRoot())
rootCmd.AddCommand(user.GetRoot())
rootCmd.AddCommand(usergroup.GetRoot())
rootCmd.AddCommand(metrics.GetRoot())
rootCmd.AddCommand(network_user.GetRoot())
rootCmd.AddCommand(host.GetRoot())
rootCmd.AddCommand(enrollment_key.GetRoot())
}
8 changes: 0 additions & 8 deletions cli/cmd/user/create.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package user

import (
"strings"

"github.com/gravitl/netmaker/cli/functions"
"github.com/gravitl/netmaker/models"
"github.com/spf13/cobra"
Expand All @@ -15,12 +13,6 @@ var userCreateCmd = &cobra.Command{
Long: `Create a new user`,
Run: func(cmd *cobra.Command, args []string) {
user := &models.User{UserName: username, Password: password, IsAdmin: admin}
if networks != "" {
user.Networks = strings.Split(networks, ",")
}
if groups != "" {
user.Groups = strings.Split(groups, ",")
}
functions.PrettyPrint(functions.CreateUser(user))
},
}
Expand Down
5 changes: 2 additions & 3 deletions cli/cmd/user/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package user
import (
"os"
"strconv"
"strings"

"github.com/gravitl/netmaker/cli/cmd/commons"
"github.com/gravitl/netmaker/cli/functions"
Expand All @@ -23,9 +22,9 @@ var userListCmd = &cobra.Command{
functions.PrettyPrint(data)
default:
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Name", "Admin", "Networks", "Groups"})
table.SetHeader([]string{"Name", "SuperAdmin", "Admin"})
for _, d := range *data {
table.Append([]string{d.UserName, strconv.FormatBool(d.IsAdmin), strings.Join(d.Networks, ", "), strings.Join(d.Groups, ", ")})
table.Append([]string{d.UserName, strconv.FormatBool(d.IsSuperAdmin), strconv.FormatBool(d.IsAdmin)})
}
table.Render()
}
Expand Down
Loading

0 comments on commit f158caf

Please sign in to comment.