Add auto-assign groups to the User API (#467)

This commit is contained in:
Misha Bragin
2022-09-22 09:06:32 +02:00
committed by GitHub
parent c75ffd0f4b
commit 518a2561a2
8 changed files with 304 additions and 65 deletions

View File

@@ -31,13 +31,33 @@ components:
description: User's name from idp provider
type: string
role:
description: User's Netbird account role
description: User's NetBird account role
type: string
auto_groups:
description: Groups to auto-assign to peers registered by this user
type: array
items:
type: string
required:
- id
- email
- name
- role
- auto_groups
UserRequest:
type: object
properties:
auto_groups:
description: Groups to auto-assign to peers registered by this user
type: array
items:
type: string
required:
- name
- type
- expires_in
- revoked
- auto_groups
PeerMinimum:
type: object
properties:
@@ -409,6 +429,40 @@ paths:
"$ref": "#/components/responses/forbidden"
'500':
"$ref": "#/components/responses/internal_error"
/api/users/{id}:
put:
summary: Update information about a User
tags: [ Users]
security:
- BearerAuth: [ ]
parameters:
- in: path
name: id
required: true
schema:
type: string
description: The User ID
requestBody:
description: User update
content:
'application/json':
schema:
$ref: '#/components/schemas/UserRequest'
responses:
'200':
description: A User object
content:
application/json:
schema:
$ref: '#/components/schemas/User'
'400':
"$ref": "#/components/responses/bad_request"
'401':
"$ref": "#/components/responses/requires_authentication"
'403':
"$ref": "#/components/responses/forbidden"
'500':
"$ref": "#/components/responses/internal_error"
/api/peers:
get:
summary: Returns a list of all peers

View File

@@ -356,6 +356,9 @@ type SetupKeyRequest struct {
// User defines model for User.
type User struct {
// Groups to auto-assign to peers registered by this user
AutoGroups []string `json:"auto_groups"`
// User's email address
Email string `json:"email"`
@@ -365,10 +368,16 @@ type User struct {
// User's name from idp provider
Name string `json:"name"`
// User's Netbird account role
// User's NetBird account role
Role string `json:"role"`
}
// UserRequest defines model for UserRequest.
type UserRequest struct {
// Groups to auto-assign to peers registered by this user
AutoGroups []string `json:"auto_groups"`
}
// PostApiGroupsJSONBody defines parameters for PostApiGroups.
type PostApiGroupsJSONBody struct {
Name string `json:"name"`
@@ -442,6 +451,9 @@ type PostApiSetupKeysJSONBody = SetupKeyRequest
// PutApiSetupKeysIdJSONBody defines parameters for PutApiSetupKeysId.
type PutApiSetupKeysIdJSONBody = SetupKeyRequest
// PutApiUsersIdJSONBody defines parameters for PutApiUsersId.
type PutApiUsersIdJSONBody = UserRequest
// PostApiGroupsJSONRequestBody defines body for PostApiGroups for application/json ContentType.
type PostApiGroupsJSONRequestBody PostApiGroupsJSONBody
@@ -477,3 +489,6 @@ type PostApiSetupKeysJSONRequestBody = PostApiSetupKeysJSONBody
// PutApiSetupKeysIdJSONRequestBody defines body for PutApiSetupKeysId for application/json ContentType.
type PutApiSetupKeysIdJSONRequestBody = PutApiSetupKeysIdJSONBody
// PutApiUsersIdJSONRequestBody defines body for PutApiUsersId for application/json ContentType.
type PutApiUsersIdJSONRequestBody = PutApiUsersIdJSONBody