From 753af5752415f5bfa22bf672481482f69d52a245 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 13 Jun 2024 17:51:07 +0300 Subject: [PATCH] MSP-3427 swagger refreshed --- .gitignore | 1 + docs/docs.go | 1685 ++++++++++++++++++++++++++++++++++++++++++++ docs/swagger.json | 1661 +++++++++++++++++++++++++++++++++++++++++++ docs/swagger.yaml | 143 +++- go.mod | 13 +- go.sum | 44 +- tests/auth_test.go | 7 +- 7 files changed, 3510 insertions(+), 44 deletions(-) create mode 100644 docs/docs.go create mode 100644 docs/swagger.json diff --git a/.gitignore b/.gitignore index fd2fff0..4d8ffb2 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,4 @@ fabric.properties google/ package.json yarn.lock +/bin/golangci-lint diff --git a/docs/docs.go b/docs/docs.go new file mode 100644 index 0000000..4e630d0 --- /dev/null +++ b/docs/docs.go @@ -0,0 +1,1685 @@ +// Package docs Code generated by swaggo/swag. DO NOT EDIT +package docs + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": {}, + "license": { + "name": "GNU GPL v3.0" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/auth/login": { + "post": { + "description": "Авторизация с получением токена администратора", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Авторизация по логину и паролю", + "parameters": [ + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.LoginRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.LoginResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "401": { + "description": "Данные для авторизации не верны", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/auth/login_with_sudir": { + "post": { + "description": "Авторизация с получением токена администратора", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Авторизация по авторизационному коду от СУДИР", + "parameters": [ + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.LoginSudirRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.LoginResponse" + } + }, + "401": { + "description": "Некорректный код для авторизации", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "412": { + "description": "Авторизация СУДИР не настроена на сервере", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/auth/logout": { + "post": { + "description": "Выход из авторизованной сессии администрирования", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Выход из авторизованной сессии", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Невалидный токен", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/log/all": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "log" + ], + "summary": "Получение списка логов", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.PageRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.AuditResponse" + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/log/events": { + "post": { + "description": "Возвращает полный список доступных событий аудита", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "log" + ], + "summary": "Получение списка логов", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.AuditResponse" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.AuditEvent" + } + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/log/set_events": { + "post": { + "description": "Всегда возвращает полный список доступных событий аудита", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "log" + ], + "summary": "Получение списка логов", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.SetAuditEvent" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/role/all": { + "post": { + "description": "Получить список ролей", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "role" + ], + "summary": "Список ролей", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.Role" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/role/create": { + "post": { + "description": "Создать роль", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Создать роль", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateRoleRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.User" + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "409": { + "description": "Роль с указанным именем уже существует", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/role/delete": { + "post": { + "description": "Удалить существующую роль", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "role" + ], + "summary": "Удалить роль", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.DeleteRoleRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/role/update": { + "post": { + "description": "Обновить данные существующую роль", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "role" + ], + "summary": "Обновить роль", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateRoleRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Role" + } + }, + "404": { + "description": "Роль с указанным id не существует", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "409": { + "description": "Роль с указанным именем уже существует", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/secure/authenticate": { + "post": { + "description": "Проверяет токен и возвращает идентификатор администратора", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "secure" + ], + "summary": "Метод аутентификации токена", + "parameters": [ + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.SecureAuthRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.SecureAuthResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/secure/authorize": { + "post": { + "description": "Проверяет наличие у администратора необходимого разрешения", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "secure" + ], + "summary": "Метод авторизации для администратора", + "parameters": [ + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.SecureAuthzRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.SecureAuthzResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/session/all": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "session" + ], + "summary": "Получение списка сессий", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.SessionRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.PageRequest" + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/session/revoke": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "session" + ], + "summary": "Отзыв сессии", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.RevokeRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/block_user": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Метод блокировки/разблокировки пользователя", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.IdRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/change_password": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Метод изменения пароля пользователя", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.ChangePasswordRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/create_user": { + "post": { + "description": "Создать пользователя", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Создать пользователя", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateUserRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.User" + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "409": { + "description": "Пользователь с указанным email уже существует", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/delete_user": { + "post": { + "description": "Удалить существующего пользователя", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Удалить пользователя", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.IdentitiesRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.DeleteResponse" + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/get_by_id": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Метод получения данных по пользователю", + "parameters": [ + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.IdRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.User" + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/get_design": { + "post": { + "description": "Получение внешнего вида (палитра и наименование) админ-интерфейса", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Получение внешнего вида", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/conf.UIDesign" + } + }, + "400": { + "description": "Невалидный токен", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/get_profile": { + "post": { + "description": "Получить данные профиля", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Получить профиль", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.AdminUserShort" + } + }, + "400": { + "description": "Невалидный токен", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "404": { + "description": "Пользователя не существует", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/get_users": { + "post": { + "description": "Получить список пользователей", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Список пользователей", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UsersRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.UsersResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/update_user": { + "post": { + "description": "Обновить данные существующего пользователя", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Обновить пользователя", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateUserRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.User" + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "404": { + "description": "Пользователь с указанным id не существует", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "409": { + "description": "Пользователь с указанным email уже существует", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + } + }, + "definitions": { + "conf.UIDesign": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "primaryColor": { + "type": "string" + } + } + }, + "domain.AdminUserShort": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "idleTimeoutMs": { + "type": "integer" + }, + "lastName": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "type": "string" + } + }, + "role": { + "type": "string" + }, + "roles": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "domain.Audit": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "message": { + "type": "string" + }, + "userId": { + "type": "integer" + } + } + }, + "domain.AuditEvent": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "event": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "domain.AuditResponse": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.Audit" + } + }, + "totalCount": { + "type": "integer" + } + } + }, + "domain.ChangePasswordRequest": { + "type": "object", + "properties": { + "newPassword": { + "type": "string" + }, + "oldPassword": { + "type": "string" + } + } + }, + "domain.CreateRoleRequest": { + "type": "object", + "properties": { + "changeMessage": { + "type": "string" + }, + "externalGroup": { + "type": "string" + }, + "name": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "domain.CreateUserRequest": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "password": { + "type": "string" + }, + "roles": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "domain.DeleteResponse": { + "type": "object", + "properties": { + "deleted": { + "type": "integer" + } + } + }, + "domain.DeleteRoleRequest": { + "type": "object", + "properties": { + "id": { + "type": "integer" + } + } + }, + "domain.GrpcError": { + "type": "object", + "properties": { + "details": { + "type": "array", + "items": {} + }, + "errorCode": { + "type": "string" + }, + "errorMessage": { + "type": "string" + } + } + }, + "domain.IdRequest": { + "type": "object", + "properties": { + "userId": { + "type": "integer" + } + } + }, + "domain.IdentitiesRequest": { + "type": "object", + "properties": { + "ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "domain.LoginRequest": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + } + } + }, + "domain.LoginResponse": { + "type": "object", + "properties": { + "expired": { + "type": "string" + }, + "headerName": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, + "domain.LoginSudirRequest": { + "type": "object", + "properties": { + "authCode": { + "type": "string" + } + } + }, + "domain.PageRequest": { + "type": "object", + "properties": { + "limit": { + "type": "integer" + }, + "offset": { + "type": "integer" + } + } + }, + "domain.Permission": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "domain.RevokeRequest": { + "type": "object", + "properties": { + "id": { + "type": "integer" + } + } + }, + "domain.Role": { + "type": "object", + "properties": { + "changeMessage": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "exclusive": { + "type": "boolean" + }, + "externalGroup": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "immutable": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "type": "string" + } + }, + "updatedAt": { + "type": "string" + } + } + }, + "domain.SecureAuthRequest": { + "type": "object", + "properties": { + "token": { + "type": "string" + } + } + }, + "domain.SecureAuthResponse": { + "type": "object", + "properties": { + "adminId": { + "type": "integer" + }, + "authenticated": { + "type": "boolean" + }, + "errorReason": { + "type": "string" + } + } + }, + "domain.SecureAuthzRequest": { + "type": "object", + "properties": { + "adminId": { + "type": "integer" + }, + "permission": { + "type": "string" + } + } + }, + "domain.SecureAuthzResponse": { + "type": "object", + "properties": { + "authorized": { + "type": "boolean" + } + } + }, + "domain.SessionRequest": { + "type": "object", + "properties": { + "limit": { + "type": "integer" + }, + "offset": { + "type": "integer" + } + } + }, + "domain.SetAuditEvent": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "event": { + "type": "string" + } + } + }, + "domain.UpdateRoleRequest": { + "type": "object", + "properties": { + "changeMessage": { + "type": "string" + }, + "externalGroup": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "domain.UpdateUserRequest": { + "type": "object", + "properties": { + "blocked": { + "type": "boolean" + }, + "description": { + "type": "string" + }, + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "lastName": { + "type": "string" + }, + "roles": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "domain.User": { + "type": "object", + "properties": { + "blocked": { + "type": "boolean" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "lastName": { + "type": "string" + }, + "lastSessionCreatedAt": { + "type": "string" + }, + "roles": { + "type": "array", + "items": { + "type": "integer" + } + }, + "updatedAt": { + "type": "string" + } + } + }, + "domain.UsersRequest": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "ids": { + "type": "array", + "items": { + "type": "integer" + } + }, + "limit": { + "type": "integer" + }, + "offset": { + "type": "integer" + } + } + }, + "domain.UsersResponse": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.User" + } + } + } + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0.0", + Host: "localhost:9000", + BasePath: "/api/admin", + Schemes: []string{}, + Title: "msp-admin-service", + Description: "сервис управления администраторами", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/docs/swagger.json b/docs/swagger.json new file mode 100644 index 0000000..d1fee09 --- /dev/null +++ b/docs/swagger.json @@ -0,0 +1,1661 @@ +{ + "swagger": "2.0", + "info": { + "description": "сервис управления администраторами", + "title": "msp-admin-service", + "contact": {}, + "license": { + "name": "GNU GPL v3.0" + }, + "version": "1.0.0" + }, + "host": "localhost:9000", + "basePath": "/api/admin", + "paths": { + "/auth/login": { + "post": { + "description": "Авторизация с получением токена администратора", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Авторизация по логину и паролю", + "parameters": [ + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.LoginRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.LoginResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "401": { + "description": "Данные для авторизации не верны", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/auth/login_with_sudir": { + "post": { + "description": "Авторизация с получением токена администратора", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Авторизация по авторизационному коду от СУДИР", + "parameters": [ + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.LoginSudirRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.LoginResponse" + } + }, + "401": { + "description": "Некорректный код для авторизации", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "412": { + "description": "Авторизация СУДИР не настроена на сервере", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/auth/logout": { + "post": { + "description": "Выход из авторизованной сессии администрирования", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Выход из авторизованной сессии", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Невалидный токен", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/log/all": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "log" + ], + "summary": "Получение списка логов", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.PageRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.AuditResponse" + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/log/events": { + "post": { + "description": "Возвращает полный список доступных событий аудита", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "log" + ], + "summary": "Получение списка логов", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.AuditResponse" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.AuditEvent" + } + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/log/set_events": { + "post": { + "description": "Всегда возвращает полный список доступных событий аудита", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "log" + ], + "summary": "Получение списка логов", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.SetAuditEvent" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/role/all": { + "post": { + "description": "Получить список ролей", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "role" + ], + "summary": "Список ролей", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.Role" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/role/create": { + "post": { + "description": "Создать роль", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Создать роль", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateRoleRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.User" + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "409": { + "description": "Роль с указанным именем уже существует", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/role/delete": { + "post": { + "description": "Удалить существующую роль", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "role" + ], + "summary": "Удалить роль", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.DeleteRoleRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/role/update": { + "post": { + "description": "Обновить данные существующую роль", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "role" + ], + "summary": "Обновить роль", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateRoleRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.Role" + } + }, + "404": { + "description": "Роль с указанным id не существует", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "409": { + "description": "Роль с указанным именем уже существует", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/secure/authenticate": { + "post": { + "description": "Проверяет токен и возвращает идентификатор администратора", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "secure" + ], + "summary": "Метод аутентификации токена", + "parameters": [ + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.SecureAuthRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.SecureAuthResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/secure/authorize": { + "post": { + "description": "Проверяет наличие у администратора необходимого разрешения", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "secure" + ], + "summary": "Метод авторизации для администратора", + "parameters": [ + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.SecureAuthzRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.SecureAuthzResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/session/all": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "session" + ], + "summary": "Получение списка сессий", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.SessionRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.PageRequest" + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/session/revoke": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "session" + ], + "summary": "Отзыв сессии", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.RevokeRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/block_user": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Метод блокировки/разблокировки пользователя", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.IdRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/change_password": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Метод изменения пароля пользователя", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.ChangePasswordRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/create_user": { + "post": { + "description": "Создать пользователя", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Создать пользователя", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.CreateUserRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.User" + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "409": { + "description": "Пользователь с указанным email уже существует", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/delete_user": { + "post": { + "description": "Удалить существующего пользователя", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Удалить пользователя", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.IdentitiesRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.DeleteResponse" + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/get_by_id": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Метод получения данных по пользователю", + "parameters": [ + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.IdRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.User" + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/get_design": { + "post": { + "description": "Получение внешнего вида (палитра и наименование) админ-интерфейса", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Получение внешнего вида", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/conf.UIDesign" + } + }, + "400": { + "description": "Невалидный токен", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/get_profile": { + "post": { + "description": "Получить данные профиля", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Получить профиль", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.AdminUserShort" + } + }, + "400": { + "description": "Невалидный токен", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "404": { + "description": "Пользователя не существует", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/get_users": { + "post": { + "description": "Получить список пользователей", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Список пользователей", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UsersRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.UsersResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + }, + "/user/update_user": { + "post": { + "description": "Обновить данные существующего пользователя", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Обновить пользователя", + "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UpdateUserRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/domain.User" + } + }, + "400": { + "description": "Невалидное тело запроса", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "404": { + "description": "Пользователь с указанным id не существует", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "409": { + "description": "Пользователь с указанным email уже существует", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" + } + } + } + } + } + }, + "definitions": { + "conf.UIDesign": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "primaryColor": { + "type": "string" + } + } + }, + "domain.AdminUserShort": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "idleTimeoutMs": { + "type": "integer" + }, + "lastName": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "type": "string" + } + }, + "role": { + "type": "string" + }, + "roles": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "domain.Audit": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "message": { + "type": "string" + }, + "userId": { + "type": "integer" + } + } + }, + "domain.AuditEvent": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "event": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "domain.AuditResponse": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.Audit" + } + }, + "totalCount": { + "type": "integer" + } + } + }, + "domain.ChangePasswordRequest": { + "type": "object", + "properties": { + "newPassword": { + "type": "string" + }, + "oldPassword": { + "type": "string" + } + } + }, + "domain.CreateRoleRequest": { + "type": "object", + "properties": { + "changeMessage": { + "type": "string" + }, + "externalGroup": { + "type": "string" + }, + "name": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "domain.CreateUserRequest": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "password": { + "type": "string" + }, + "roles": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "domain.DeleteResponse": { + "type": "object", + "properties": { + "deleted": { + "type": "integer" + } + } + }, + "domain.DeleteRoleRequest": { + "type": "object", + "properties": { + "id": { + "type": "integer" + } + } + }, + "domain.GrpcError": { + "type": "object", + "properties": { + "details": { + "type": "array", + "items": {} + }, + "errorCode": { + "type": "string" + }, + "errorMessage": { + "type": "string" + } + } + }, + "domain.IdRequest": { + "type": "object", + "properties": { + "userId": { + "type": "integer" + } + } + }, + "domain.IdentitiesRequest": { + "type": "object", + "properties": { + "ids": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "domain.LoginRequest": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + } + } + }, + "domain.LoginResponse": { + "type": "object", + "properties": { + "expired": { + "type": "string" + }, + "headerName": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, + "domain.LoginSudirRequest": { + "type": "object", + "properties": { + "authCode": { + "type": "string" + } + } + }, + "domain.PageRequest": { + "type": "object", + "properties": { + "limit": { + "type": "integer" + }, + "offset": { + "type": "integer" + } + } + }, + "domain.Permission": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "domain.RevokeRequest": { + "type": "object", + "properties": { + "id": { + "type": "integer" + } + } + }, + "domain.Role": { + "type": "object", + "properties": { + "changeMessage": { + "type": "string" + }, + "createdAt": { + "type": "string" + }, + "exclusive": { + "type": "boolean" + }, + "externalGroup": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "immutable": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "type": "string" + } + }, + "updatedAt": { + "type": "string" + } + } + }, + "domain.SecureAuthRequest": { + "type": "object", + "properties": { + "token": { + "type": "string" + } + } + }, + "domain.SecureAuthResponse": { + "type": "object", + "properties": { + "adminId": { + "type": "integer" + }, + "authenticated": { + "type": "boolean" + }, + "errorReason": { + "type": "string" + } + } + }, + "domain.SecureAuthzRequest": { + "type": "object", + "properties": { + "adminId": { + "type": "integer" + }, + "permission": { + "type": "string" + } + } + }, + "domain.SecureAuthzResponse": { + "type": "object", + "properties": { + "authorized": { + "type": "boolean" + } + } + }, + "domain.SessionRequest": { + "type": "object", + "properties": { + "limit": { + "type": "integer" + }, + "offset": { + "type": "integer" + } + } + }, + "domain.SetAuditEvent": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + }, + "event": { + "type": "string" + } + } + }, + "domain.UpdateRoleRequest": { + "type": "object", + "properties": { + "changeMessage": { + "type": "string" + }, + "externalGroup": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "domain.UpdateUserRequest": { + "type": "object", + "properties": { + "blocked": { + "type": "boolean" + }, + "description": { + "type": "string" + }, + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "lastName": { + "type": "string" + }, + "roles": { + "type": "array", + "items": { + "type": "integer" + } + } + } + }, + "domain.User": { + "type": "object", + "properties": { + "blocked": { + "type": "boolean" + }, + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "lastName": { + "type": "string" + }, + "lastSessionCreatedAt": { + "type": "string" + }, + "roles": { + "type": "array", + "items": { + "type": "integer" + } + }, + "updatedAt": { + "type": "string" + } + } + }, + "domain.UsersRequest": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "ids": { + "type": "array", + "items": { + "type": "integer" + } + }, + "limit": { + "type": "integer" + }, + "offset": { + "type": "integer" + } + } + }, + "domain.UsersResponse": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.User" + } + } + } + } + } +} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 81d9387..55eafc3 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -13,6 +13,8 @@ definitions: type: string firstName: type: string + idleTimeoutMs: + type: integer lastName: type: string permissions: @@ -25,8 +27,6 @@ definitions: items: type: integer type: array - required: - - email type: object domain.Audit: properties: @@ -57,6 +57,13 @@ definitions: totalCount: type: integer type: object + domain.ChangePasswordRequest: + properties: + newPassword: + type: string + oldPassword: + type: string + type: object domain.CreateRoleRequest: properties: changeMessage: @@ -86,9 +93,6 @@ definitions: items: type: integer type: array - required: - - email - - password type: object domain.DeleteResponse: properties: @@ -103,8 +107,7 @@ definitions: domain.GrpcError: properties: details: - items: - type: object + items: {} type: array errorCode: type: string @@ -115,8 +118,6 @@ definitions: properties: userId: type: integer - required: - - userId type: object domain.IdentitiesRequest: properties: @@ -124,8 +125,6 @@ definitions: items: type: integer type: array - required: - - ids type: object domain.LoginRequest: properties: @@ -133,9 +132,6 @@ definitions: type: string password: type: string - required: - - email - - password type: object domain.LoginResponse: properties: @@ -150,8 +146,6 @@ definitions: properties: authCode: type: string - required: - - authCode type: object domain.PageRequest: properties: @@ -159,8 +153,6 @@ definitions: type: integer offset: type: integer - required: - - limit type: object domain.Permission: properties: @@ -173,8 +165,6 @@ definitions: properties: id: type: integer - required: - - id type: object domain.Role: properties: @@ -213,6 +203,18 @@ definitions: errorReason: type: string type: object + domain.SecureAuthzRequest: + properties: + adminId: + type: integer + permission: + type: string + type: object + domain.SecureAuthzResponse: + properties: + authorized: + type: boolean + type: object domain.SessionRequest: properties: limit: @@ -260,8 +262,6 @@ definitions: items: type: integer type: array - required: - - id type: object domain.User: properties: @@ -400,7 +400,7 @@ paths: - application/json responses: "200": - description: "" + description: OK "400": description: Невалидный токен schema: @@ -504,7 +504,7 @@ paths: - application/json responses: "200": - description: "" + description: OK "400": description: Невалидное тело запроса schema: @@ -607,7 +607,7 @@ paths: - application/json responses: "200": - description: "" + description: OK "400": description: Невалидное тело запроса schema: @@ -664,11 +664,6 @@ paths: - application/json description: Проверяет токен и возвращает идентификатор администратора parameters: - - description: Токен администратора - in: header - name: X-AUTH-ADMIN - required: true - type: string - description: Тело запроса in: body name: body @@ -689,6 +684,32 @@ paths: summary: Метод аутентификации токена tags: - secure + /secure/authorize: + post: + consumes: + - application/json + description: Проверяет наличие у администратора необходимого разрешения + parameters: + - description: Тело запроса + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.SecureAuthzRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/domain.SecureAuthzResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.GrpcError' + summary: Метод авторизации для администратора + tags: + - secure /session/all: post: consumes: @@ -743,7 +764,7 @@ paths: - application/json responses: "200": - description: "" + description: OK "400": description: Невалидное тело запроса schema: @@ -775,7 +796,7 @@ paths: - application/json responses: "200": - description: "" + description: OK "400": description: Невалидное тело запроса schema: @@ -787,6 +808,38 @@ paths: summary: Метод блокировки/разблокировки пользователя tags: - user + /user/change_password: + post: + consumes: + - application/json + parameters: + - description: Токен администратора + in: header + name: X-AUTH-ADMIN + required: true + type: string + - description: Тело запроса + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.ChangePasswordRequest' + produces: + - application/json + responses: + "200": + description: OK + "400": + description: Невалидное тело запроса + schema: + $ref: '#/definitions/domain.GrpcError' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.GrpcError' + summary: Метод изменения пароля пользователя + tags: + - user /user/create_user: post: consumes: @@ -923,17 +976,33 @@ paths: post: consumes: - application/json - description: Получить все разрашения + description: Получить данные профиля + parameters: + - description: Токен администратора + in: header + name: X-AUTH-ADMIN + required: true + type: string produces: - application/json responses: "200": description: OK schema: - items: - $ref: '#/definitions/domain.Permission' - type: array - summary: Получить все разрашения + $ref: '#/definitions/domain.AdminUserShort' + "400": + description: Невалидный токен + schema: + $ref: '#/definitions/domain.GrpcError' + "404": + description: Пользователя не существует + schema: + $ref: '#/definitions/domain.GrpcError' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.GrpcError' + summary: Получить профиль tags: - user /user/get_users: diff --git a/go.mod b/go.mod index 7695b78..c4fae79 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/google/uuid v1.6.0 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.9.0 + github.com/swaggo/swag v1.16.3 github.com/txix-open/bgjob v1.4.0 github.com/txix-open/isp-kit v1.31.4 github.com/txix-open/jsonschema v1.2.0 @@ -18,6 +19,9 @@ require ( require ( github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect + github.com/KyleBanks/depth v1.2.1 // indirect + github.com/PuerkitoBio/purell v1.1.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/buger/jsonparser v1.1.1 // indirect @@ -29,6 +33,10 @@ require ( github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/jsonreference v0.19.6 // indirect + github.com/go-openapi/spec v0.20.4 // indirect + github.com/go-openapi/swag v0.19.15 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect @@ -38,6 +46,7 @@ require ( github.com/jackc/pgx/v5 v5.5.5 // indirect github.com/jackc/puddle/v2 v2.2.1 // indirect github.com/jmoiron/sqlx v1.4.0 // indirect + github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect @@ -71,13 +80,15 @@ require ( go.opentelemetry.io/proto/otlp v1.2.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/net v0.24.0 // indirect + golang.org/x/net v0.25.0 // indirect golang.org/x/sys v0.21.0 // indirect golang.org/x/text v0.16.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.11 // indirect ) diff --git a/go.sum b/go.sum index 3d5d4d5..11acc44 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,14 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8= github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU= +github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= +github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM= github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa h1:LHTHcTQiSGT7VVbI0o4wBRNQIgn917usHWOd6VAffYI= github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= @@ -18,6 +24,7 @@ github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK3 github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -40,6 +47,16 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs= +github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= +github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M= +github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= +github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= @@ -88,13 +105,17 @@ github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZ github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o= github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw= @@ -105,6 +126,9 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -122,6 +146,7 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -153,6 +178,7 @@ github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -160,6 +186,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/swaggo/swag v1.16.3 h1:PnCYjPCah8FK4I26l2F/KQ4yz3sILcVUN3cTlBFA9Pg= +github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI/gRk= github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY= github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o= github.com/txix-open/bgjob v1.4.0 h1:yfo0AgJKBa27nD34mHhV4YcDn4xfCXScDQw7WTigCZo= @@ -217,17 +245,20 @@ golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -235,6 +266,7 @@ golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -252,6 +284,7 @@ golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= @@ -262,6 +295,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be h1:Zz7rLWqp0ApfsR/l7+zSHhY3PMiH2xqgxlfYfAfNpoU= google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be/go.mod h1:dvdCTIoAGbkWbcIKBniID56/7XHTt6WfxXNMxuziJ+w= @@ -272,12 +307,17 @@ google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLp google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI= diff --git a/tests/auth_test.go b/tests/auth_test.go index fbd3d50..f9a2329 100644 --- a/tests/auth_test.go +++ b/tests/auth_test.go @@ -179,7 +179,7 @@ func (s *AuthTestSuite) initMockSudir() (*httptest.Server, string) { AccessToken: "token", } data, err := json.Marshal(res) - s.NoError(err) + s.Require().NoError(err) _, err = writer.Write(data) s.NoError(err) }) @@ -193,7 +193,7 @@ func (s *AuthTestSuite) initMockSudir() (*httptest.Server, string) { FamilyName: "surname", } data, err := json.Marshal(res) - s.NoError(err) + s.Require().NoError(err) _, err = writer.Write(data) s.NoError(err) }) @@ -262,8 +262,7 @@ func (s *AuthTestSuite) TestBruteForceLogin() { tooManyRequestsErrorCount := &atomic.Int32{} unauthorizedErrorCount := &atomic.Int32{} group, ctx := errgroup.WithContext(context.Background()) - for i := range 100 { - index := i + for index := range 100 { group.Go(func() error { start := time.Now() response := domain.LoginResponse{}