Commit graph

81 commits

Author SHA1 Message Date
Vishal Dalwadi
67baa75f45 feat(go): skip setting open connections; 2025-06-10 15:26:42 +05:30
Vishal Dalwadi
da5115221f fix(go): workflow errors fixes; 2025-06-06 15:42:30 +05:30
Vishal Dalwadi
48957c02fa feat(go): use single db handle; use connection pool; 2025-06-06 15:26:23 +05:30
Vishal Dalwadi
614cf77b5a
NET-1991: Add IDP sync functionality. (#3428)
* 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

* fix revoked tokens to be unauthorized

* 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

* feat(go): add types for idp package;

* feat(go): import azure sdk;

* feat(go): add stub for google workspace client;

* feat(go): implement azure ad client;

* feat(go): sync users and groups using idp client;

* publish peer update on settings update

* feat(go): read creds from env vars;

* feat(go): add api endpoint to trigger idp sync;

* fix(go): sync member changes;

* fix(go): handle error;

* fix(go): set correct response type;

* feat(go): support disabling user accounts;

1. Add api endpoints to enable and disable user accounts.
2. Add checks in authenticators to prevent disabled users from logging in.
3. Add checks in middleware to prevent api usage by disabled users.

* feat(go): use string slice for group members;

* feat(go): sync user account status from idp;

* feat(go): import google admin sdk;

* feat(go): add support for google workspace idp;

* feat(go): initialize idp client on sync;

* feat(go): sync from idp periodically;

* feat(go): improvements for google idp;

1. Use the impersonate package to authenticate.
2. Use Pages method to get all data.

* 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.

* feat(go): add db middleware;

* feat(go): restore method;

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

* fix user auth api:

* re initalise oauth and email config

* feat(go): fetch idp creds from server settings;

* feat(go): add filters for users and groups;

* feat(go): skip sync from idp if disabled;

* feat(go): add endpoint to remove idp integration;

* feat(go): import all users if no filters;

* feat(go): assign service-user role on sync;

* feat(go): remove microsoft-go-sdk;

* feat(go): add display name field for user;

* fix(go): set account disabled correctly;

* fix(go): update user if display name changes;

* fix(go): remove auth provider when removing idp integration;

* fix(go): ignore display name if empty;

* feat(go): add idp sync interval setting;

* fix(go): error on invalid auth provider;

* fix(go): no error if no user on group delete;

* fix(go): check superadmin using platform role id;

* feat(go): add display name and account disabled to return user as well;

* feat(go): tidy go mod after merge;

* feat(go): reinitialize auth provider and idp sync hook;

* fix(go): merge error;

* fix(go): merge error;

* feat(go): use id as the external provider id;

* fix(go): comments;

* feat(go): add function to return pending users;

* feat(go): prevent external id erasure;

* fix(go): user and group sync errors;

* chore(go): cleanup;

* fix(go): delete only oauth users;

* feat(go): use uuid group id;

* export ipd id to in rest api

* feat(go): don't use uuid for default groups;

* feat(go): migrate group only if id not uuid;

* chore(go): go mod tidy;

---------

Co-authored-by: abhishek9686 <abhi281342@gmail.com>
Co-authored-by: Abhishek K <abhishek@netmaker.io>
Co-authored-by: the_aceix <aceixsmartx@gmail.com>
2025-05-21 13:48:15 +05:30
Abhishek K
309e4795a1
NET-1950: Persist Server Settings in the DB (#3419)
* 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

* fix revoked tokens to be unauthorized

* 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

* publish peer update on settings 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.

* feat(go): add db middleware;

* feat(go): restore method;

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

* fix user auth api:

* re initalise oauth and email config

* set verbosity

* sync auto update settings with hosts

* sync auto update settings with hosts

* mask secret and convert jwt duration to minutes

* convert jwt duration to minutes

* notify peers after settings update

* compare with curr settings before updating

* send host update to devices on auto update

---------

Co-authored-by: Vishal Dalwadi <dalwadivishal26@gmail.com>
2025-04-30 02:34:10 +04:00
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
Vishal Dalwadi
7f40371ffd
Task/DB-Migration: Add Key-Value to SQL Migration functionality. (#3380)
* feat(go): add db package;

* feat(go): add jobs table;

* feat(go): add schema migration facade;

* refactor(go): use custom key type to avoid collisions;
2025-04-12 14:07:57 +04:00
Abhishek K
c02ec193db
NET-1920: Add disconnected node status (#3300)
* create peer ack table

* add restricted status

* add disconnected status
2025-01-28 11:26:12 +05:30
abhishek9686
5b49872d5d fix update acl policy 2024-09-26 21:00:04 +04:00
abhishek9686
e258f12ecb set Acl DB crud 2024-09-24 19:09:15 +04:00
abhishek9686
d64f098181 Tag CRUD APIs 2024-09-17 19:34:45 +04:00
Abhishek K
2e8d95e80e
NET-1227: User Mgmt V2 (#3055)
* user mgmt models

* define user roles

* define models for new user mgmt and groups

* oauth debug log

* initialize user role after db conn

* print oauth token in debug log

* user roles CRUD apis

* user groups CRUD Apis

* additional api checks

* add additional scopes

* add additional scopes url

* add additional scopes url

* rm additional scopes url

* setup middlleware permission checks

* integrate permission check into middleware

* integrate permission check into middleware

* check for headers for subjects

* refactor user role models

* refactor user groups models

* add new user to pending user via RAC login

* untracked

* allow multiple groups for an user

* change json tag

* add debug headers

* refer network controls form roles, add debug headers

* refer network controls form roles, add debug headers

* replace auth checks, add network id to role model

* nodes handler

* migration funcs

* invoke sync users migration func

* add debug logs

* comment middleware

* fix get all nodes api

* add debug logs

* fix middleware error nil check

* add new func to get username from jwt

* fix jwt parsing

* abort on error

* allow multiple network roles

* allow multiple network roles

* add migration func

* return err if jwt parsing fails

* set global check to true when accessing user apis

* set netid for acls api calls

* set netid for acls api calls

* update role and groups routes

* add validation checks

* add invite flow apis and magic links

* add invited user via oauth signup automatically

* create invited user on oauth signup, with groups in the invite

* add group validation for user invite

* update create user handler with new role mgmt

* add validation checks

* create user invites tables

* add error logging for email invite

* fix invite singup url

* debug log

* get query params from url

* get query params from url

* add query escape

* debug log

* debug log

* fix user signup via invite api

* set admin field for backward compatbility

* use new role id for user apis

* deprecate use of old admin fields

* deprecate usage of old user fields

* add user role as service user if empty

* setup email sender

* delete invite after user singup

* add plaform user role

* redirect on invite verification link

* fix invite redirect

* temporary redirect

* fix invite redirect

* point invite link to frontend

* fix query params lookup

* add resend support, configure email interface types

* fix groups and user creation

* validate user groups, add check for metrics api in middleware

* add invite url to invite model

* migrate rac apis to new user mgmt

* handle network nodes

* add platform user to default role

* fix user role migration

* add default on rag creation and cleanup after deletion

* fix rac apis

* change to invite code param

* filter nodes and hosts based on user network access

* extend create user group req to accomodate users

* filter network based on user access

* format oauth error

* move user roles and groups

* fix get user v1 api

* move user mgmt func to pro

* add user auth type to user model

* fix roles init

* remove platform role from group object

* list only platform roles

* add network roles to invite req

* create default groups and roles

* fix middleware for global access

* create default role

* fix nodes filter with global network roles

* block selfupdate of groups and network roles

* delete netID if net roles are empty

* validate user roles nd groups on update

* set extclient permission scope when rag vpn access is set

* allow deletion of roles and groups

* replace _ with - in role naming convention

* fix failover middleware mgmt

* format oauth templates

* fetch route temaplate

* return err if user wrong login type

* check user groups on rac apis

* fix rac apis

* fix resp msg

* add validation checks for admin invite

* return oauth type

* format group err msg

* fix html tag

* clean up default groups

* create default rag role

* add UI name to roles

* remove default net group from user when deleted

* reorder migration funcs

* fix duplicacy of hosts

* check old field for migration

* from pro to ce make all secondary users admins

* from pro to ce make all secondary users admins

* revert: from pro to ce make all secondary users admins

* make sure downgrades work

* fix pending users approval

* fix duplicate hosts

* fix duplicate hosts entries

* fix cache reference issue

* feat: configure FRONTEND_URL during installation

* disable user vpn access when network roles are modified

* rm vpn acces when roles or groups are deleted

* add http to frontend url

* revert crypto version

* downgrade crytpo version

* add platform id check on user invites

---------

Co-authored-by: the_aceix <aceixsmartx@gmail.com>
2024-08-20 17:08:56 +05:30
Abhishek K
0d4552db5e
NET-1064: Oauth User SignUp Approval Flow (#2874)
* add pending users api

* insert user to pending users on first time oauth login

* add pending user check on headless login

* fix conflicting apis

* no records error

* add allowed emails domains for oauth singup to config

* check if user is allowed to signup
2024-04-03 11:20:19 +05:30
Seongbin Hong
ea235a5d3f
Merge branch 'develop' into bugfix_v0.22.0_bump-gorqlite-to-a8a425b1a6aa 2024-01-25 20:25:45 +09:00
VertexToEdge
f7118d6cf7 Bump github.com/rqlite/gorqlite from v0.0.0-20210514125552-08ff1e76b22f to v0.0.0-20240122221808-a8a425b1a6aa 2024-01-24 20:54:22 +09:00
abhishek9686
6749fb4516 add trial license logic 2024-01-19 14:51:51 +05:30
0xdcarns
2e6eaac274 moved data structure to db 2023-03-03 14:23:51 -05:00
0xdcarns
a5e7147b69 initial commit, began unit tests 2023-02-14 17:21:51 -05:00
0xdcarns
d6b1fb4b17 added rwmutex to db calls 2023-02-09 19:30:59 -05:00
0xdcarns
7a2c225eb1 added mq and database connected funcs and endpoint 2023-02-06 12:09:21 -05:00
0xdcarns
cc529ab3bd finished initial crud for hosts, fixed stun server close bug 2022-12-19 14:55:24 -05:00
0xdcarns
88cd0a6497 initial commit 2022-09-13 15:25:56 -04:00
0xdcarns
de91533372 added better state management to make OAuth sign-ins HA 2022-08-04 10:03:39 -04:00
afeiszli
b281047168 adding functions to handle certs in DB 2022-06-30 21:56:11 -04:00
Matthew R. Kasun
2c00f96a71 remove unused function 2022-06-27 10:35:34 -04:00
0xdcarns
5e327fdea4 set max open conns to 1 for sqlite 2022-03-21 09:14:04 -04:00
0xdcarns
9d0d3ea732 added mutex for sqlite 2022-03-15 22:37:30 -04:00
0xdcarns
6061ccec76 began ACL implementation 2022-03-10 14:55:40 -05:00
afeiszli
1c06cfc8f7 modified getpeers for hub network 2022-02-18 11:43:49 -05:00
0xdcarns
ad79f2ea1f addresses review comments 2022-01-29 18:18:46 -05:00
0xdcarns
95b9444325 log cleanup 2022-01-29 18:18:46 -05:00
0xdcarns
410efbab50 switched to eliptical strategy 2022-01-29 18:18:46 -05:00
0xdcarns
3dadb8dcbf added e.. 2022-01-29 18:18:46 -05:00
0xdcarns
aa22afeb95 tracking mod 2022-01-29 18:18:46 -05:00
0xdcarns
ac632a75b7 refactored struct 2022-01-29 18:18:46 -05:00
0xdcarns
3483e45beb added struct to model 2022-01-29 18:18:46 -05:00
0xdcarns
c40c905b3b edited chunk size 2022-01-29 18:18:46 -05:00
0xdcarns
c748594c02 data adapt 2022-01-29 18:18:46 -05:00
0xdcarns
90fcddb588 log add 2022-01-29 18:18:46 -05:00
0xdcarns
2b5c5afeb4 remove some logs 2022-01-29 18:18:46 -05:00
0xdcarns
fb69d54f24 change key size 2022-01-29 18:18:46 -05:00
0xdcarns
48d6d57f25 trying again 2022-01-29 18:18:46 -05:00
0xdcarns
50c95f66cb node debug 2022-01-29 18:18:46 -05:00
0xdcarns
7be2b0e09d adjusted to byte buffer 2022-01-29 18:18:46 -05:00
0xdcarns
d27dee0691 debugging 2022-01-29 18:18:46 -05:00
0xdcarns
0015d6fdf8 added encryption/decryption strategy 2022-01-29 18:18:46 -05:00
0xdcarns
7846420fa7 added timer hooks 2022-01-25 11:00:56 -05:00
afeiszli
aa4baa5503 fixing minor things for code review 2022-01-23 09:39:48 -05:00
afeiszli
e3e239ab84 adding code review changes 2022-01-22 10:12:33 -05:00
afeiszli
351a2ac5a8 switch time to 24 hour checkins 2022-01-21 14:16:28 -05:00