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
This commit is contained in:
Abhishek K
2025-04-23 20:21:42 +04:00
committed by GitHub
parent d5bdc723fc
commit ca95954fb5
28 changed files with 507 additions and 200 deletions

View File

@@ -61,7 +61,7 @@ func sqliteCreateTable(tableName string) error {
}
func sqliteInsert(key string, value string, tableName string) error {
if key != "" && value != "" && IsJSONString(value) {
if key != "" && value != "" {
insertSQL := "INSERT OR REPLACE INTO " + tableName + " (key, value) VALUES (?, ?)"
statement, err := SqliteDB.Prepare(insertSQL)
if err != nil {
@@ -78,7 +78,7 @@ func sqliteInsert(key string, value string, tableName string) error {
}
func sqliteInsertPeer(key string, value string) error {
if key != "" && value != "" && IsJSONString(value) {
if key != "" && value != "" {
err := sqliteInsert(key, value, PEERS_TABLE_NAME)
if err != nil {
return err