61 Commits

Author SHA1 Message Date
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
Abhishek Kondur c2423bf20b NM-213: JIT Network Access (#3830)
* NM-213: JIT access

* NM-213: handle expiry duration in epoch

* NM-213: avoid jit checks for admins

* NM-213: add jit expiry field to extclient

* NM-213: format jit emails

* NM-213: format jit email templates

* NM-213: update jit expiry on existing clients

* NM-213: update jit expiry on existing clients
2026-01-31 11:45:16 +04:00
Abhishek Kondur a51649a1df NM-205: Overlapping egress ranges (#3820)
* NM-205: init virtual NAT for egress ranges

* NM-205: add virtual NAT to egress peer update model

* NM-205: add virtual nat to allowed ips if present

* NM-205: fix create api, update nat fields

* NM-205: fix virtual nat range assignment

* NM-210: use virtual ranges for allowed ips for egress ips

* NM-205: allows update of nat settings

* NM-205: fix migration of egress virtual ranges

* NM-205: fix update operations

* NM-205: if domain range is set,overiride nat setting to direct

* NM-205: validate NAT pool fields on net update, add nat mode egress metric range struct

* NM-205: fix nat egress range

* NM-205: add virtual egress ranges to extclient allowed Ips

* NM-205: add overlapping egress ranges

* NM-205: match egress cidr for virtual nat if less than prefix length

* NM-205: match egress cidr for virtual nat if less than prefix length

* NM-205: force update overlapping egress feature flag

* NM-205: disable virtual nat for ipv6

* NM-205: simplify egress update ops

* NM-205: fix tests

* NM-205: NAT pool update with prefix length validation

* NM-205: send virtual egress ranges for non egress nodes

* NM-205: assign virtual NAT on creation
2026-01-29 14:36:52 +04:00
Abhishek Kondur 94f3716fdf Merge pull request #3744 from gravitl/NM-167
NM-167: Auto delete Offline Nodes
2025-12-05 09:52:53 +04:00
Abhishek K a8a0dd066c NM-44: Device Approvals for Network Join (#3579)
* add pending hosts apis, migration logic for network auto join field

* fix pending hosts logic on join

* delete pending hosts on host delete

* ignore pedning device request if host in the network already

* add peer update on host approval
2025-08-12 09:16:51 +05:30
abhishek9686 21826d41b6 add nameservers to network settings 2025-02-28 21:27:18 +04:00
Abhishek K 4431dc99a7 NET-1933: option to force destroy network (#3311)
* option to force destroy network

* fix network tests

* fix network defaults func

* fix network destroy action

* delete network if node count is zero

* push peer update network deletion

* send node update
2025-02-03 15:19:44 +04:00
Yabin Ma 1d9e0f71df add format int64 for swagger doc (#3247)
* add format int64 for swagger doc

* add format int64 for swagger doc

* add global override

* swagger doc update

* add new line for .swaggo file
2024-12-12 09:52:52 +04:00
Abhishek K d58439ac9d api for network with stats (#3111) 2024-09-26 11:52:21 +04:00
Abhishek K a9a237cafc check if new network is overlapping (#2655) 2023-11-08 17:43:20 +04:00
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
Farukh Khan 449f3f947b Net 509 515 (#2496)
* NET-509

* External client config files with IPv6 endpoints now have the [] separating the address and port.

* NET-515

* Increased network name max length to 32

* NET-509-515

* Updated unit test for network name max length check.

* Updated extclient endpoint ip string manipulation to use sprintf

* Added proper error message for network name length more than max allowed.

* NET-515 small typo fix for error strings should not be capitalized
2023-08-08 23:17:22 +05:30
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
0xdcarns 0b7df753f7 removed references to AccessKey model 2023-03-13 16:02:44 -04:00
Matthew R Kasun 828b3f7162 remove local network/range 2023-02-26 16:28:16 -05:00
Matthew R Kasun 77cfae41ff remove postup/down 2023-02-02 11:16:54 -05:00
Matthew R Kasun 4e3ff513b7 remove point to site from network model 2023-01-30 10:47:40 -05:00
Matthew R Kasun 9edb541388 remove localrange 2023-01-20 05:42:05 -05:00
0xdcarns 88cd0a6497 initial commit 2022-09-13 15:25:56 -04:00
cameronts 38e4950ed1 Fixed by adding validation tags.
To test: run go test ./... -test.v (tested with go 1.18.4).
2022-07-20 12:32:48 -07:00
0xdcarns 99abd9666d removed required status for ipv6 and added check on create network 2022-04-25 13:10:55 -04:00
0xdcarns 8e976d1f55 removed isdualstack references 2022-04-25 13:09:23 -04:00
0xdcarns 611a425852 added more uniform unique address checks 2022-04-25 13:08:45 -04:00
Matthew R. Kasun 747d6bc692 remove comms network leftovers
Signed-off-by: Matthew R. Kasun <mkasun@nusak.ca>
2022-04-22 05:21:35 -04:00
0xdcarns 5ba79afeba added default acl value option for networks 2022-03-17 13:24:57 -04:00
afeiszli f21dad5184 fixed hub logic 2022-02-21 09:45:42 -05:00
0xdcarns 6028e1b6de added comms checks 2022-02-18 19:37:12 -05:00
afeiszli f55eeedbb9 settings for comms network 2022-02-18 11:11:21 -05:00
afeiszli 8cd19c20c6 removed unnecessary variables from network, added IsHubAndSpoke 2022-02-18 09:49:58 -05:00
0xdcarns cd4e2c57d6 added new struct and adapted to funcs 2022-01-29 18:15:52 -05:00
0xdcarns 0d3813295d server update 2022-01-29 18:15:52 -05:00
0xdcarns 26a0d8bdbe initial commit 2022-01-29 18:15:52 -05:00
0xdcarns 8f72ecbaa0 refactored logic 2021-10-26 12:50:34 -04:00
0xdcarns d7cafbbc4c code linting 2021-10-08 15:07:12 -04:00
afeiszli 21ba362eca allowing IsServer to be modified, configurable checkin time, single checkin for linux, moved cfg files 2021-10-02 12:28:17 -04:00
0xdcarns 90d941854b made some more efficient images and added set defaults for node reads 2021-09-27 17:51:20 -04:00
0xdcarns 34717417ce began windows userspace implementation 2021-09-10 13:39:51 -04:00
worker-9 c2a9007b8c automated ext client egress range addition and ext client dns from network 2021-08-25 09:46:45 -04:00
afeiszli 8056f024e2 client mode enablement 2021-08-19 13:41:04 -04:00
worker-9 e029979ab6 I push 2021-08-05 12:39:01 -04:00
worker-9 44d03f6805 began refactoring of client 2021-08-05 12:24:16 -04:00
afeiszli 12c4fa33f5 v0.7 2021-07-28 02:23:20 +00:00
afeiszli fd223e3d4a refactored nodes model 2021-07-24 16:13:24 -04:00
afeiszli a982b62445 refactoring validation and models 2021-07-23 18:24:34 -04:00
afeiszli 93b0b94788 Mid way through adopting rqlite 2021-07-21 18:55:19 -04:00
afeiszli b33f5b2fab fixing validation 2021-07-11 10:28:50 -04:00
afeiszli 977da6b129 compiling with changes pushed for json token. Have NOT TESTED. Will probably run into issues. Need to test multiple egress ranges, AllowedIPs, and overriding connection strings. 2021-07-11 00:49:31 -04:00
afeiszli ccce74be97 added setting node limits 2021-07-02 23:25:36 -04:00
afeiszli 8e9a0b46aa test changes 2021-05-27 17:21:28 -04:00
afeiszli 78ae219b03 major overhaul initiated 2021-05-25 12:48:04 -04:00