mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 01:07:41 +08:00
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:
@@ -59,7 +59,7 @@ func pgCreateTable(tableName string) error {
|
||||
}
|
||||
|
||||
func pgInsert(key string, value string, tableName string) error {
|
||||
if key != "" && value != "" && IsJSONString(value) {
|
||||
if key != "" && value != "" {
|
||||
insertSQL := "INSERT INTO " + tableName + " (key, value) VALUES ($1, $2) ON CONFLICT (key) DO UPDATE SET value = $3;"
|
||||
statement, err := PGDB.Prepare(insertSQL)
|
||||
if err != nil {
|
||||
@@ -77,7 +77,7 @@ func pgInsert(key string, value string, tableName string) error {
|
||||
}
|
||||
|
||||
func pgInsertPeer(key string, value string) error {
|
||||
if key != "" && value != "" && IsJSONString(value) {
|
||||
if key != "" && value != "" {
|
||||
err := pgInsert(key, value, PEERS_TABLE_NAME)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user