Commit Graph

75 Commits

Author SHA1 Message Date
Abhishek Kondur c3c3ed1fb8 NM-254: add bulk delete apis, rm old acl code (#3937)
* NM-254: add bulk delete apis for users, hosts, nodes and optimise postgres connection settings

* NM-254: rm debug logs

* NM-254: add bulk delete apis, remove old acl code

* NM-254: rm unused flag

* NM-254: fix bulk delete bugs, add security and performance improvements

- Fix host delete notifying peers before confirming deletion from DB
- Fix self-delete vulnerability in bulk user delete
- Fix DissasociateNodeFromHost failing when host.Nodes is empty
- Fix AssociateNodeToHost/DissasociateNodeFromHost stale read race
- Hoist GetAllExtClients outside loop in bulk user delete/status
- Move initializeUUID outside master-pod guard for HA correctness

* NM-254: return 202 Accepted for async bulk APIs, fix relay allowedIPs and host association error handling

- Change all bulk endpoints (hosts, nodes, users, ext clients) from
  200 OK to 202 Accepted to correctly signal async processing
- Add ReturnAcceptedResponse helper in logic/errors.go
- Fix GetAllowedIpsForRelayed returning empty allowedIPs slice,
  restoring relay connectivity
- Make AssociateNodeToHost and DissasociateNodeFromHost return an
  error when the host DB re-fetch fails instead of silently using
  stale data
- Add bulk-apis.md documenting all five bulk endpoints

* NM-254: rm coredns container

* NM-254: add bulk apis for node,extclient status, add activity logs to bulk apis

* NM-254: add bulk api for connection toggle

* NM-254: add network check

* Update controllers/hosts.go

Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>

* NM-254: optimise bulk extclient deletion

---------

Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>
2026-03-26 10:15:07 +05:30
Abhishek Kondur edda2868fc NM-163: Users, Groups, Roles, Networks and Hosts Table Migration (#3910)
* feat(go): add user schema;

* feat(go): migrate to user schema;

* feat(go): add audit fields;

* feat(go): remove unused fields from the network model;

* feat(go): add network schema;

* feat(go): migrate to network schema;

* refactor(go): add comment to clarify migration logic;

* fix(go): test failures;

* fix(go): test failures;

* feat(go): change membership table to store memberships at all scopes;

* feat(go): add schema for access grants;

* feat(go): remove nameservers from new networks table; ensure db passed for schema functions;

* feat(go): set max conns for sqlite to 1;

* fix(go): issues updating user account status;

* refactor(go): remove converters and access grants;

* refactor(go): add json tags in schema models;

* refactor(go): rename file to migrate_v1_6_0.go;

* refactor(go): add user groups and user roles tables; use schema tables;

* refactor(go): inline get and list from schema package;

* refactor(go): inline get network and list users from schema package;

* fix(go): staticcheck issues;

* fix(go): remove test not in use; fix test case;

* fix(go): validate network;

* fix(go): resolve static checks;

* fix(go): new models errors;

* fix(go): test errors;

* fix(go): handle no records;

* fix(go): add validations for user object;

* fix(go): set correct extclient status;

* fix(go): test error;

* feat(go): make schema the base package;

* feat(go): add host schema;

* feat(go): use schema host everywhere;

* feat(go): inline get host, list hosts and delete host;

* feat(go): use non-ptr value;

* feat(go): use save to upsert all fields;

* feat(go): use save to upsert all fields;

* feat(go): save turn endpoint as string;

* feat(go): check for gorm error record not found;

* fix(go): test failures;

* fix(go): update all network fields;

* fix(go): update all network fields;

* feat(go): add paginated list networks api;

* feat(go): add paginated list users api;

* feat(go): add paginated list hosts api;

* feat(go): add pagination to list groups api;

* fix(go): comment;

* fix(go): implement marshal and unmarshal text for custom types;

* fix(go): implement marshal and unmarshal json for custom types;

* fix(go): just use the old model for unmarshalling;

* fix(go): implement marshal and unmarshal json for custom types;

* feat(go): remove paginated list networks api;

* feat(go): use custom paginated response object;

* fix(go): ensure default values for page and per_page are used when not passed;

* fix(go): rename v1.6.0 to v1.5.1;

* fix(go): check for gorm.ErrRecordNotFound instead of database.IsEmptyRecord;

* fix(go): use host id, not pending host id;

* feat(go): add filters to paginated apis;

* feat(go): add filters to paginated apis;

* feat(go): remove check for max username length;

* feat(go): add filters to count as well;

* feat(go): use library to check email address validity;

* feat(go): ignore pagination if params not passed;

* fix(go): pagination issues;

* fix(go): check exists before using;

* fix(go): remove debug log;

* fix(go): use gorm err record not found;

* fix(go): use gorm err record not found;

* fix(go): use user principal name when creating pending user;

* fix(go): use schema package for consts;

* fix(go): prevent disabling superadmin user;

Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>

* fix(go): swap is admin and is superadmin;

Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>

* fix(go): remove dead code block;

https://github.com/gravitl/netmaker/pull/3910#discussion_r2928837937

* fix(go): incorrect message when trying to disable self;

https://github.com/gravitl/netmaker/pull/3910#discussion_r2928837934

* fix(go): use correct header;

Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>

* fix(go): return after error response;

Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>

* fix(go): use correct order of params;

https://github.com/gravitl/netmaker/pull/3910#discussion_r2929593036

* fix(go): set default values for page and page size; use v2 instead of /list;

* Update logic/auth.go

Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>

* Update schema/user_roles.go

Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>

* fix(go): syntax error;

* fix(go): set default values when page and per_page are not passed or 0;

* fix(go): use uuid.parse instead of uuid.must parse;

* fix(go): review errors;

* fix(go): review errors;

* Update controllers/user.go

Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>

* Update controllers/user.go

Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>

* NM-163: fix errors:

* Update db/types/options.go

Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>

* fix(go): persist return user in event;

* Update db/types/options.go

Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>

* NM-163: duplicate lines of code

* NM-163: fix(go): fix missing return and filter parsing in user controller

- Add missing return after error response in updateUserAccountStatus
  to prevent double-response and spurious ext-client side-effects
- Use switch statements in listUsers to skip unrecognized
  account_status and mfa_status filter values

* fix(go): check for both min and max page size;

* fix(go): enclose transfer superadmin in transaction;

* fix(go): review errors;

* fix(go): remove free tier checks;

* fix(go): review fixes;

---------

Co-authored-by: VishalDalwadi <dalwadivishal26@gmail.com>
Co-authored-by: Vishal Dalwadi <51291657+VishalDalwadi@users.noreply.github.com>
Co-authored-by: tenki-reviewer[bot] <262613592+tenki-reviewer[bot]@users.noreply.github.com>
2026-03-17 19:36:52 +05:30
abhishek9686 d8dcc37941 remove duplicate cli table pkg 2025-06-24 07:11:46 +05:30
Aceix 506f73ebb9 Merge pull request #3441 from gravitl/nmctl-access-token
feat: add support for user access tokens in nmctl
2025-05-20 09:16:24 +05:30
Aceix af19704f41 fix: alias device subcommand with host (#3431) 2025-04-30 02:58:52 +04:00
Aceix 163b04966f fix: correct ids of static and user nodes (#3421)
- fix static and user node ids
- enhance output by adding a "Type" column
2025-04-30 02:57:11 +04:00
abhishek9686 76311f072d add loadbalance endpoint for extclients 2025-03-02 20:59:27 +04:00
Vishal Dalwadi 9a7c13b8a6 NET-1962: add gateway subcommand. (#3339)
* feat(go): add deprecation warning.

* feat(go): add support for gateway commands.

* feat(go): mention the server version in which the commands were deprecated.
2025-02-24 08:50:10 +03:00
Aceix f0601849a5 fix: update documentation links to new docs (#3156) 2024-10-17 14:35:36 +04:00
Abhishek K 5a4d0663da NET-1227: User Cli cmds Update (#3064)
* generalise smtp config

* copy over smtp vars

* env new line

* fix master key api access

* comment user tests

* fix network and user invite for master key access

* remove email sender type

* user mgmt commands

* check user role on CE

* user role nmtcl cmds

* user groups commands

* fix role and groups command

* fix user create cmd

* add usage info

* rm user role check

* fix user update cmd

* fix static check
2024-08-25 07:25:40 +05:30
Max Ma c7469c79d0 rename isstaticendpoint to isstatic 2024-06-03 10:37:19 +02:00
Max Ma 81a6c9cf8a seperate static port and static endpoint 2024-05-28 10:16:11 +02:00
Max Ma 5740c3e009 Net 1115 (#2890)
* add endpointipv6 for host

* keep endpointipv6 unchanged when enable static endpoint

* handle ipv6 endpoint updates

---------

Co-authored-by: abhishek9686 <abhi281342@gmail.com>
2024-04-11 17:37:45 +05:30
Max Ma e0bde5b67f Net 1088 (#2872)
* fix ipv6 only issue

* fix InetGw ipv6 issue

* refactor constants for NET1088

* fix extClient IPv6 empty issue
2024-04-09 11:50:07 +05:30
Max Ma b59658024c add enable/disable failover in nmctl command (#2857) 2024-03-20 15:12:42 +07:00
pwillis7 3b533952df NET-1050: change ingress refs in NMCTL to remote access gateways (#2852) 2024-03-12 08:17:34 +07:00
Aceix 61d6b2fa3f fix(NET-799): fix acl allow/deny subcommands (#2736) 2023-12-20 13:30:45 +04:00
Aceix 8aa185d880 feat(NET-678): add saas support to nmctl (#2687)
* feat(NET-678): add saas support to nmctl

* fix(NET-678): fix context endpoint for sso
2023-12-13 14:04:09 +04:00
Gabriel de Souza Seibel cb4b99ffcb [NET-562] Persistent Keep Alive from node to host (#2604)
* Move PKA field from models node to host level

* Move PKA field from api models node to host level

* Adapt logic package to node->host PKA

* Adapt migration-related code to node->host PKA

* Adapt cli code to node->host PKA

* Change host PKA default to 20s

* On IfaceDelta, check for PKA on host

* On handleHostRegister, set default PKA

* Use a default PKA

* Use int64 for api host pka

* Reorder imports

* Don't use host pka in iface delta

* Fix ConvertAPIHostToNMHost

* Add swagger doc for host PKA field

* Fix swagger.yml

* Set default PKA only for new hosts

* Remove TODO comment

* Remove redundant check

* Have api-host pka be specified in seconds
2023-10-06 10:09:19 +04:00
Matthew R Kasun 823182cf09 add force flag to host/node delete (#2548)
* add force flag to host/node delete

* review comments

---------

Co-authored-by: Abhishek K <32607604+abhishek9686@users.noreply.github.com>
2023-09-13 10:10:17 +05:30
Matthew R Kasun 1e2fae0652 remove node uncordon (#2549) 2023-09-11 09:48:42 +05:30
Abhishek K 719e0c254d NET-551: User Mgmt Re-Design (#2547)
* add superadmin role, apis to create superadmin user

* apis to attach and remove user from remote access gateways

* add api to list user's remote client has gateway clients

* remove code related user groups

* remove networks and groups from user model

* refactor user CRUD operations

* fix network permission test

* add superadmin to authorize func

* remove user network and groups from cli

* api to transfer superadmin role

* add api to list users on a ingress gw

* restrict user access to resources on server

* deny request from remote access client if extclient is already created

* fix user tests

* fix static checks

* fix static checks

* add limits to extclient create handler

* set username to superadmin on if masterkey is used

* allow creation of extclients using masterkey

* add migration func to assign superadmin role for existing admin user

* check for superadmin on migration if users are present

* allowe masterkey to extcleint apis

* check ownerid

* format error, on jwt token verification failure return unauthorized rather than forbidden

* user update fix

* move user remote functionality to ee

* fix update user api

* security patch

* initalise ee user handlers

* allow user to use master key to update any user

* use slog

* fix auth user test

* table headers

* remove user role, it's covered in middleware

* setuser defaults fix
2023-09-01 14:27:08 +05:30
Abhishek K 645bc4c126 NET-447: Removed proxy related fields and code (#2459)
* remove related fields and code

* remover metrics collection from server code

* fw update struct

* add ext client flag to metrics data

* simply nat types

* rm proxy update from cli
2023-07-26 11:22:49 +05:30
Abhishek K 6c2582651c Net-137: Node relays (#2401)
* revert relays

* initial relay commit

* get relayed allowed ips

* add more relay validation checks, peer logic cleanup

* rm relayed nodes from relay node when relayed node is deleted

* fix egress updates for relayed nodes

* rm unused func

* remove  debug logs

* avoid adding egress ranges on the relayed gw node

---------

Co-authored-by: Matthew R Kasun <mkasun@nusak.ca>
2023-06-19 12:26:14 -04:00
Matthew R Kasun 78640f1342 Extclient NET-63x (#2286)
* model changes

* additional fields for extclient create

* add DNS to extclient config

* extclient name checks

* update extclient

* nmctl extclient

* final tweaks

* review comments

* add extclientdns to node on ingress creation

* fix to add ingress dns to api (#2296)

---------

Co-authored-by: Aceix <aceixsmartX@gmail.com>
2023-05-17 10:58:03 -04:00
dcarns 249cf5f474 Merge pull request #2205 from gravitl/GRA-1529n-key-update
Gra 1529n key update
2023-04-18 17:06:35 -04:00
Matthew R Kasun 34eb699752 deprecated ability to edit networks 2023-04-14 10:39:36 -04:00
Matthew R Kasun 12004aa09a refactor key updates on host basis vice node 2023-04-13 16:08:39 -04:00
0xdcarns 0b7df753f7 removed references to AccessKey model 2023-03-13 16:02:44 -04:00
Anish Mukherjee 8e09684def add json format output alternative to tables 2023-03-06 12:08:46 +05:30
Anish Mukherjee 9e8f41f491 remove [--args] from definition 2023-03-02 17:45:10 +05:30
Anish Mukherjee c5311c0cd5 add enrollment key to nmctl 2023-03-02 17:40:31 +05:30
Matthew R Kasun 828b3f7162 remove local network/range 2023-02-26 16:28:16 -05:00
Anish Mukherjee 6a03947384 update host network modification endpoints 2023-02-14 17:25:22 +05:30
Abhishek Kondur 98c70e8a20 pr comments 2023-02-06 22:46:50 +04:00
Matthew R Kasun 77cfae41ff remove postup/down 2023-02-02 11:16:54 -05:00
Matthew R Kasun 92af578ab1 remove point to site from nmctl 2023-01-30 11:04:22 -05:00
dcarns d22a38a4d0 Merge pull request #1972 from gravitl/bugfix_nmctl_host_default
Fix nmctl host update
2023-01-25 12:48:00 -05:00
Anish Mukherjee ebb1349228 fix nmctl node update 2023-01-25 18:02:30 +05:30
Anish Mukherjee 5c1d91ad72 fix host update 2023-01-25 16:34:48 +05:30
Anish Mukherjee 02ba1ce6ae move relay logic to hosts 2023-01-24 16:00:12 +05:30
Matthew R Kasun 9edb541388 remove localrange 2023-01-20 05:42:05 -05:00
Anish Mukherjee f04828f1d4 update node models to ApiNode 2023-01-16 10:32:26 +05:30
Anish Mukherjee 905f5ef5e2 add flags for host update 2023-01-06 10:28:08 +05:30
Anish Mukherjee e600fe32ed remove toggle flag 2023-01-06 10:09:35 +05:30
Anish Mukherjee 46f4f4f4c6 minor refactor 2023-01-05 19:27:42 +05:30
Anish Mukherjee 90ef4fd168 use new node structs 2023-01-05 19:25:47 +05:30
Anish Mukherjee 016e7fd2f9 cleanup comments 2023-01-05 18:53:12 +05:30
Anish Mukherjee 8b5eb0cbd4 add host endpoints to cli 2023-01-05 18:53:12 +05:30
dcarns ae6a12b16b Merge pull request #1887 from gravitl/feature_cli_sso
Add headless oauth login endpoint for CLI
2023-01-03 13:27:18 -05:00