Commit graph

82 commits

Author SHA1 Message Date
abhishek9686
12b5f1d813 remove extclients on network destroy action 2025-06-23 06:34:51 +05:30
Abhishek K
307a3d1e4b
NET-1932: Merge egress and internet gateways (#3436)
* feat: api access tokens

* revoke all user tokens

* redefine access token api routes, add auto egress option to enrollment keys

* add server settings apis, add db table for settigs

* handle server settings updates

* switch to using settings from DB

* fix sever settings migration

* revet force migration for settings

* fix server settings database write

* egress model

* fix revoked tokens to be unauthorized

* update egress model

* remove unused functions

* convert access token to sql schema

* switch access token to sql schema

* fix merge conflicts

* fix server settings types

* bypass basic auth setting for super admin

* add TODO comment

* setup api handlers for egress revamp

* use single DB, fix update nat boolean field

* extend validaiton checks for egress ranges

* add migration to convert to new egress model

* fix panic interface conversion

* publish peer update on settings update

* revoke token generated by an user

* add user token creation restriction by user role

* add forbidden check for access token creation

* revoke user token when group or role is changed

* add default group to admin users on update

* chore(go): import style changes from migration branch;

1. Singular file names for table schema.
2. No table name method.
3. Use .Model instead of .Table.
4. No unnecessary tagging.

* remove nat check on egress gateway request

* Revert "remove nat check on egress gateway request"

This reverts commit 0aff12a189.

* remove nat check on egress gateway request

* feat(go): add db middleware;

* feat(go): restore method;

* feat(go): add user access token schema;

* add inet gw status to egress model

* fetch node ids in the tag, add inet gw info clients

* add inet gw info to node from egress list

* add migration logic internet gws

* create default acl policies

* add egress info

* add egress TODO

* add egress TODO

* fix user auth api:

* add reference id to acl policy

* add egress response from DB

* publish peer update on egress changes

* re initalise oauth and email config

* set verbosity

* normalise cidr on egress req

* add egress id to acl group

* change acls to use egress id

* resolve merge conflicts

* fix egress reference errors

* move egress model to schema

* add api context to DB

* sync auto update settings with hosts

* sync auto update settings with hosts

* check acl for egress node

* check for egress policy in the acl dst groups

* fix acl rules for egress policies with new models

* add status to egress model

* fix inet node func

* mask secret and convert jwt duration to minutes

* enable egress policies on creation

* convert jwt duration to minutes

* add relevant ranges to inet egress

* skip non active egress routes

* resolve merge conflicts

* fix static check

* update gorm tag for primary key on egress model

* create user policies for egress resources

* resolve merge conflicts

* get egress info on failover apis, add egress src validation for inet gws

* add additional validation checks on egress req

* add additional validation checks on egress req

* skip all resources for inet policy

* delete associated egress acl policies

* fix failover of inetclient

* avoid setting inet client asd inet gw

* fix all resource egress policy

* fix inet gw egress rule

* check for node egress on relay req

* fix egress acl rules comms

* add new field for egress info on node

* check acl policy in failover ctx

* avoid default host to be set as inet client

* fix relayed egress node

* add valid error messaging for egress validate func

* return if inet default host

* jump port detection to 51821

* check host ports on pull

* check user access gws via acls

* add validation check for default host and failover for inet clients

* add error messaging for acl policy check

* fix inet gw status

* ignore failover req for peer using inet gw

* check for allowed egress ranges for a peer

* add egress routes to static nodes by access

* avoid setting failvoer as inet client

* fix egress error messaging

* fix extclients egress comms

* fix inet gw acting as inet client

* return formatted error on update acl validation

* add default route for static nodes on inetclient

* check relay node acting as inetclient

* move inet node info to separate field, fix all resouces policy

* remove debug logs

---------

Co-authored-by: Vishal Dalwadi <dalwadivishal26@gmail.com>
2025-05-21 12:50:21 +05:30
Abhishek K
ca95954fb5
NET-2000: Api access tokens (#3418)
* feat: api access tokens

* revoke all user tokens

* redefine access token api routes, add auto egress option to enrollment keys

* fix revoked tokens to be unauthorized

* remove unused functions

* convert access token to sql schema

* switch access token to sql schema

* revoke token generated by an user

* add user token creation restriction by user role

* add forbidden check for access token creation

* revoke user token when group or role is changed

* add default group to admin users on update

* fix token removal on user update

* fix token removal on user update
2025-04-23 20:21:42 +04:00
abhishek9686
225bf37e02 resolve merge conflicts 2025-02-28 12:18:38 +04:00
abhishek9686
ce6ec25253 fix network ip allocation in HA 2025-02-27 16:26:15 +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
abhishek9686
56d5c85da7 block default key deletion,delete default key on network deletion 2024-10-30 15:58:55 +04:00
abhishek9686
0ddbf7958e fix rebase errors 2024-10-30 12:02:42 +04:00
abhishek9686
636b2ff1a7 create enrollment key on network creation 2024-10-24 12:47:53 +04:00
Max Ma
bbca20e463
NET-1565:fix extClient ip conflict issue (#3082)
* fix extClient ip conflict issue

* Update users.go

---------

Co-authored-by: Abhishek K <abhishek@netmaker.io>
2024-08-28 18:58:07 +05:30
Max Ma
46b8fd21c8
NET-1440: scale test changes (#3014)
* NET-1440 scale test changes

* fix UT error and add error info

* load metric data into cacha in startup

* remove debug info for metric

* add server telemetry and hasSuperAdmin to cache

* fix user UT case

* update sqlite connection string for performance

* update check-in TS in cache only if cache enabled

* update metric data in cache only if cache enabled and write to DB once in stop

* update server status in mq topic

* add failover existed to server status update

* only send mq messsage when there is server status change

* batch peerUpdate

* code changes for scale for review

* update UT case

* update mq client check

* mq connection code change

* revert server status update changes

* revert batch peerUpdate

* remove server status update info

* code changes based on review and setupmqtt in keepalive

* set the mq message order to false for PIN

* remove setupmqtt in keepalive

* recycle ip in node deletion

* update ip allocation logic

* remove ip addr cap

* remove ippool file

* update get extClient func

* remove ip from cache map when extClient is removed
2024-08-15 11:59:00 +05:30
loselarry
fa32c2ac58
chore: fix function names in comment (#2888)
Signed-off-by: loselarry <bikangning@yeah.net>
2024-04-11 21:04:24 +05:30
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
Gabriel de Souza Seibel
7e8b66e03d
[NET-353] Solve race condition with "unique" ips (#2461)
* Use a lock for getting unique ips

* Make getting & setting unique ips atomic

* Remove some blank lines

* Set addressLock to &sync.Mutex on declaration
2023-07-27 11:34:15 +05:30
Abhishek Kondur
50e093b456 cache ext clients 2023-06-27 20:48:53 +05:30
Abhishek Kondur
27ac920069 cache acls 2023-06-27 16:12:06 +05:30
Abhishek Kondur
4071bb2bac db cache nodes and hosts 2023-06-27 16:10:04 +05:30
Matthew R Kasun
de111181bf restore sortNetworks 2023-04-19 14:06:39 -04:00
Matthew R Kasun
57723b7aae merge conflicts 2023-04-19 13:18:03 -04:00
Matthew R Kasun
c510846444
Merge branch 'develop' into GRA-1529-key-update 2023-04-19 13:16:09 -04:00
Matthew R Kasun
63552891ee refactor key updates on host basis vice node 2023-04-13 15:02:14 -04:00
walkerwmanuel
9e56135424 Added user sorting and fixed error 2023-04-03 14:36:38 -04:00
walkerwmanuel
09872e9ec5 added sort logic 2023-03-30 16:04:12 -04:00
dcarns
3119170797
Merge pull request #2071 from gravitl/GRA-1277-public-keys
skip legacy nodes when setting node.Action
2023-03-20 15:03:58 -04:00
0xdcarns
578609ff78 added legacy update 2023-03-20 15:03:12 -04:00
0xdcarns
0b7df753f7 removed references to AccessKey model 2023-03-13 16:02:44 -04:00
Matthew R Kasun
8255643ddf skip legacy nodes when setting node.Action 2023-02-25 09:49:04 -05:00
Abhishek Kondur
051f60343b reset ingress to older way 2023-01-25 15:35:45 +04:00
Matthew R Kasun
9edb541388 remove localrange 2023-01-20 05:42:05 -05:00
Abhishek Kondur
e9dd9ac0a4 fix fetching uniqueIp 2023-01-13 19:11:40 +05:30
Matthew R. Kasun
319193c18a update IsIPUnique
also:
 - remove unnecessary call to UpertHost in create node
 - remove debugging logs
2022-12-23 18:06:59 -05:00
Matthew R. Kasun
38cd4d7700 refactor join
also removes server node
suspect there may be issues with proxy
and UI interactions with nodes
2022-12-20 15:29:09 -05:00
Matthew R. Kasun
c086e9499d rebase
Signed-off-by: Matthew R. Kasun <mkasun@nusak.ca>
2022-12-19 15:15:35 -05:00
Anish Mukherjee
0dcc54dc49 fix ipv6 addressing bug 2022-11-29 10:11:47 -05:00
Matthew R. Kasun
4df672de68 refactor node deletion 2022-11-15 09:52:17 -05:00
Abhishek Kondur
f632bec11d merge conflicts resolved 2022-09-26 17:47:20 +05:30
afeiszli
b5a3ad7dbd add * to allowed groups by default 2022-09-14 14:33:08 -04:00
afeiszli
b670755cce refactoring for ee 2022-09-14 13:26:31 -04:00
0xdcarns
88cd0a6497 initial commit 2022-09-13 15:25:56 -04:00
Alex Feiszli
6a6b55623a
Merge pull request #1514 from gravitl/feature_v0.15.1_normalize_networks
normalize cidr on network/egress gateway creation
2022-09-12 11:51:35 -04:00
Matthew R. Kasun
7ec8c4be2a use RunCmd for postup/postdown 2022-09-09 14:15:10 -04:00
Matthew R. Kasun
6b42cbe120 normalize cidr on network/egress gateway creation 2022-09-03 08:55:49 -04:00
Matthew R. Kasun
3a1dd8dc1e remove func NetworkNodesUpdatePullChanges 2022-08-18 04:49:35 -04:00
dcarns
3f2a56d03e
Merge pull request #1266 from gravitl/bugfix_v0.14.5_static_checks
eliminate static check warnings
2022-06-30 10:24:09 -04:00
Matthew R. Kasun
075a0aafd4 don't allow . in network name 2022-06-27 14:08:59 -04:00
Matthew R. Kasun
f65925c70c remove unused function 2022-06-27 12:50:28 -04:00
Matthew R. Kasun
b217d526fa fix network validation tests 2022-06-27 10:23:11 -04:00
Matthew R. Kasun
c2e22926a4 do not permit uppercase in Network names 2022-06-06 17:28:00 -04:00
Matthew R. Kasun
c37fa49096 switch to smaller ip lib 2022-05-26 16:14:52 -04:00