diff --git a/controller/audit.go b/controller/audit.go index c29282f..e658865 100644 --- a/controller/audit.go +++ b/controller/audit.go @@ -29,13 +29,14 @@ func NewAudit(service AuditService) Audit { // All // @Tags log // @Summary Получение списка логов +// @Description `errorCode: 400` - если тело запроса невалидно // @Accept json // @Produce json // @Param X-AUTH-ADMIN header string true "Токен администратора" -// @Param body body domain.AuditPageRequest true "Тело запроса" +// @Param body body domain.AuditPageRequest true "Тело запроса (пагинация, сортировка, фильтры)" // @Success 200 {object} domain.AuditResponse -// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса" -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error "Невалидное тело запроса" +// @Failure 500 {object} apierrors.Error // @Router /log/all [POST] func (c Audit) All(ctx context.Context, req domain.AuditPageRequest) (*domain.AuditResponse, error) { if req.Order == nil { @@ -50,15 +51,13 @@ func (c Audit) All(ctx context.Context, req domain.AuditPageRequest) (*domain.Au // Events // @Tags log -// @Summary Получение списка логов +// @Summary Получение списка событий аудита // @Description Возвращает полный список доступных событий аудита // @Accept json // @Produce json // @Param X-AUTH-ADMIN header string true "Токен администратора" -// @Param body body domain.AuditResponse true "Тело запроса" // @Success 200 {array} domain.AuditEvent -// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса" -// @Failure 500 {object} domain.GrpcError +// @Failure 500 {object} apierrors.Error // @Router /log/events [POST] func (c Audit) Events(ctx context.Context) ([]domain.AuditEvent, error) { return c.service.Events(ctx) @@ -66,15 +65,15 @@ func (c Audit) Events(ctx context.Context) ([]domain.AuditEvent, error) { // SetEvents // @Tags log -// @Summary Получение списка логов -// @Description Всегда возвращает полный список доступных событий аудита +// @Summary Установить события аудита +// @Description Устанавливает (обновляет) набор активных событий аудита. `errorCode: ` - если передано неизвестное событие аудита // @Accept json // @Produce json // @Param X-AUTH-ADMIN header string true "Токен администратора" -// @Param body body domain.SetAuditEvent true "Тело запроса" -// @Success 200 -// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса" -// @Failure 500 {object} domain.GrpcError +// @Param body body []domain.SetAuditEvent true "Список событий аудита для установки" +// @Success 200 {object} map[string]interface{} "События успешно установлены" +// @Failure 400 {object} apierrors.Error "Неизвестное событие аудита" +// @Failure 500 {object} apierrors.Error // @Router /log/set_events [POST] func (c Audit) SetEvents(ctx context.Context, req []domain.SetAuditEvent) error { err := c.service.SetEvents(ctx, req) diff --git a/controller/auth.go b/controller/auth.go index 51a0e25..7ca2801 100644 --- a/controller/auth.go +++ b/controller/auth.go @@ -38,9 +38,9 @@ func NewAuth(authService authService, logger log.Logger) Auth { // @Accept json // @Produce json // @Param X-AUTH-ADMIN header string true "Токен администратора" -// @Success 200 -// @Failure 400 {object} domain.GrpcError "Невалидный токен" -// @Failure 500 {object} domain.GrpcError +// @Success 200 {object} map[string]interface{} "Успешный выход" +// @Failure 400 {object} apierrors.Error "Невалидный токен" +// @Failure 500 {object} apierrors.Error // @Router /auth/logout [POST] func (a Auth) Logout(ctx context.Context, r *http.Request) error { adminId, err := getAdminId(r) @@ -62,11 +62,11 @@ func (a Auth) Logout(ctx context.Context, r *http.Request) error { // @Description Выход по бездействию из авторизованной сессии администрирования // @Accept json // @Produce json -// @Param body body domain.LogoutRequest true "Тело запроса" // @Param X-AUTH-ADMIN header string true "Токен администратора" -// @Success 200 -// @Failure 400 {object} domain.GrpcError "Невалидный токен" -// @Failure 500 {object} domain.GrpcError +// @Param body body domain.LogoutRequest true "Тело запроса" +// @Success 200 {object} map[string]interface{} "Успешный выход" +// @Failure 400 {object} apierrors.Error "Невалидный токен" +// @Failure 500 {object} apierrors.Error // @Router /auth/logout_with_reason [POST] func (a Auth) LogoutWithReason(ctx context.Context, logoutRequest domain.LogoutRequest, r *http.Request) error { adminId, err := getAdminId(r) @@ -90,9 +90,10 @@ func (a Auth) LogoutWithReason(ctx context.Context, logoutRequest domain.LogoutR // @Produce json // @Param body body domain.LoginRequest true "Тело запроса" // @Success 200 {object} domain.LoginResponse -// @Failure 400 {object} domain.GrpcError -// @Failure 401 {object} domain.GrpcError "Данные для авторизации не верны" -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error +// @Failure 401 {object} apierrors.Error "Данные для авторизации не верны" +// @Failure 429 {object} apierrors.Error "Слишком много запросов на авторизацию" +// @Failure 500 {object} apierrors.Error // @Router /auth/login [POST] func (a Auth) Login(ctx context.Context, authRequest domain.LoginRequest) (*domain.LoginResponse, error) { auth, err := a.authService.Login(ctx, authRequest) @@ -115,14 +116,14 @@ func (a Auth) Login(ctx context.Context, authRequest domain.LoginRequest) (*doma // LoginWithOauth // @Tags auth // @Summary Авторизация по авторизационному коду от OAuth -// @Description Авторизация с получением токена администратора +// @Description Авторизация с получением токена администратора. `errorCode: ` - OAuth не настроен, `` - неверный код или неизвестный клиент // @Accept json // @Produce json // @Param body body domain.LoginOauthRequest true "Тело запроса" // @Success 200 {object} domain.LoginResponse -// @Failure 401 {object} domain.GrpcError "Некорректный код для авторизации или неизвестное название клиента" -// @Failure 412 {object} domain.GrpcError "Авторизация OAuth не настроена на сервере" -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error "Авторизация OAuth не настроена на сервере" +// @Failure 401 {object} apierrors.Error "Некорректный код для авторизации или неизвестное название клиента" +// @Failure 500 {object} apierrors.Error // @Router /auth/login_with_oauth [POST] func (a Auth) LoginWithOauth(ctx context.Context, request domain.LoginOauthRequest) (*domain.LoginResponse, error) { auth, err := a.authService.LoginWithOauth(ctx, request) diff --git a/controller/customization.go b/controller/customization.go index 3c5492b..3681fe7 100644 --- a/controller/customization.go +++ b/controller/customization.go @@ -26,8 +26,8 @@ func NewCustomization(uiCfg conf.UIDesign) Customization { // @Produce json // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Success 200 {object} domain.UIDesign -// @Failure 400 {object} domain.GrpcError "Невалидный токен" -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error "Невалидный токен" +// @Failure 500 {object} apierrors.Error // @Router /user/get_design [POST] func (c Customization) GetUIDesign() (domain.UIDesign, error) { return c.uiCfg, nil diff --git a/controller/download.go b/controller/download.go index e1d4d81..7cabac1 100644 --- a/controller/download.go +++ b/controller/download.go @@ -33,7 +33,7 @@ func NewDownload(service DownloadService) Download { // @Produce json // @Param body body domain.UsersDownloadRequest true "Тело запроса" // @Success 200 -// @Failure 500 {object} domain.BusinessError "Внутренняя ошибка сервиса ```{errorCode: -1}```" +// @Failure 500 {object} apierrors.Error "Внутренняя ошибка сервиса ```{errorCode: -1}```" // @Router /user/download [POST] func (c Download) Users(ctx context.Context, req domain.UsersDownloadRequest, w http.ResponseWriter) error { err := c.service.DownloadUsers(ctx, req, w) @@ -51,7 +51,7 @@ func (c Download) Users(ctx context.Context, req domain.UsersDownloadRequest, w // @Produce json // @Param body body domain.SessionDownloadRequest true "Тело запроса" // @Success 200 -// @Failure 500 {object} domain.BusinessError "Внутренняя ошибка сервиса ```{errorCode: -1}```" +// @Failure 500 {object} apierrors.Error "Внутренняя ошибка сервиса ```{errorCode: -1}```" // @Router /session/download [POST] func (c Download) Sessions(ctx context.Context, req domain.SessionDownloadRequest, w http.ResponseWriter) error { err := c.service.DownloadSessions(ctx, req, w) @@ -69,7 +69,7 @@ func (c Download) Sessions(ctx context.Context, req domain.SessionDownloadReques // @Produce json // @Param body body domain.AuditDownloadRequest true "Тело запроса" // @Success 200 -// @Failure 500 {object} domain.BusinessError "Внутренняя ошибка сервиса ```{errorCode: -1}```" +// @Failure 500 {object} apierrors.Error "Внутренняя ошибка сервиса ```{errorCode: -1}```" // @Router /log/download [POST] func (c Download) Audit(ctx context.Context, req domain.AuditDownloadRequest, w http.ResponseWriter) error { err := c.service.DownloadAudit(ctx, req, w) @@ -86,7 +86,7 @@ func (c Download) Audit(ctx context.Context, req domain.AuditDownloadRequest, w // @Accept json // @Produce json // @Success 200 -// @Failure 500 {object} domain.BusinessError "Внутренняя ошибка сервиса ```{errorCode: -1}```" +// @Failure 500 {object} apierrors.Error "Внутренняя ошибка сервиса ```{errorCode: -1}```" // @Router /role/download [POST] func (c Download) Roles(ctx context.Context, w http.ResponseWriter) error { err := c.service.DownloadRoles(ctx, w) diff --git a/controller/permissions.go b/controller/permissions.go index 61f7c21..e8afb81 100644 --- a/controller/permissions.go +++ b/controller/permissions.go @@ -22,11 +22,12 @@ func NewPermissions(permissionsService permissionsService) Permissions { // GetPermissions // @Tags user -// @Summary Получить все разрашения -// @Description Получить все разрашения +// @Summary Получить все разрешения +// @Description Получить все разрешения // @Accept json // @Produce json // @Success 200 {array} domain.Permission +// @Failure 500 {object} apierrors.Error // @Router /user/get_permissions [POST] func (u Permissions) GetPermissions(ctx context.Context) []domain.Permission { return u.permissionsService.All(ctx) diff --git a/controller/role.go b/controller/role.go index 7dbc61c..876bacf 100644 --- a/controller/role.go +++ b/controller/role.go @@ -36,8 +36,8 @@ func NewRole(roleService roleService) Role { // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Param body body domain.RoleAllRequest true "Тело запроса" // @Success 200 {array} domain.Role -// @Failure 400 {object} domain.GrpcError -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error +// @Failure 500 {object} apierrors.Error // @Router /role/all [POST] func (u Role) All(ctx context.Context, req domain.RoleAllRequest) ([]domain.Role, error) { users, err := u.roleService.All(ctx, req) @@ -49,17 +49,17 @@ func (u Role) All(ctx context.Context, req domain.RoleAllRequest) ([]domain.Role } // CreateRole -// @Tags user +// @Tags role // @Summary Создать роль // @Description Создать роль // @Accept json // @Produce json // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Param body body domain.CreateRoleRequest true "Тело запроса" -// @Success 200 {object} domain.User -// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса" -// @Failure 409 {object} domain.GrpcError "Роль с указанным именем уже существует" -// @Failure 500 {object} domain.GrpcError +// @Success 200 {object} domain.Role +// @Failure 400 {object} apierrors.Error "Невалидное тело запроса" +// @Failure 409 {object} apierrors.Error "Роль с указанным именем уже существует" +// @Failure 500 {object} apierrors.Error // @Router /role/create [POST] func (u Role) CreateRole(ctx context.Context, req domain.CreateRoleRequest, r *http.Request) (*domain.Role, error) { adminId, err := getAdminId(r) @@ -87,9 +87,9 @@ func (u Role) CreateRole(ctx context.Context, req domain.CreateRoleRequest, r *h // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Param body body domain.UpdateRoleRequest true "Тело запроса" // @Success 200 {object} domain.Role -// @Failure 404 {object} domain.GrpcError "Роль с указанным id не существует" -// @Failure 409 {object} domain.GrpcError "Роль с указанным именем уже существует" -// @Failure 500 {object} domain.GrpcError +// @Failure 404 {object} apierrors.Error "Роль с указанным id не существует" +// @Failure 409 {object} apierrors.Error "Роль с указанным именем уже существует" +// @Failure 500 {object} apierrors.Error // @Router /role/update [POST] func (u Role) UpdateRole(ctx context.Context, req domain.UpdateRoleRequest, r *http.Request) (*domain.Role, error) { adminId, err := getAdminId(r) @@ -119,8 +119,8 @@ func (u Role) UpdateRole(ctx context.Context, req domain.UpdateRoleRequest, r *h // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Param body body domain.DeleteRoleRequest true "Тело запроса" // @Success 200 -// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса" -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error "Невалидное тело запроса" +// @Failure 500 {object} apierrors.Error // @Router /role/delete [POST] func (u Role) DeleteRole(ctx context.Context, req domain.DeleteRoleRequest, r *http.Request) error { adminId, err := getAdminId(r) diff --git a/controller/secure.go b/controller/secure.go index 3b79e11..4b78e0a 100644 --- a/controller/secure.go +++ b/controller/secure.go @@ -32,7 +32,7 @@ func NewSecure(service SecureService) Secure { // @Produce json // @Param body body domain.SecureAuthRequest true "Тело запроса" // @Success 200 {object} domain.SecureAuthResponse -// @Failure 500 {object} domain.GrpcError +// @Failure 500 {object} apierrors.Error // @Router /secure/authenticate [POST] func (s Secure) Authenticate(ctx context.Context, req domain.SecureAuthRequest) (*domain.SecureAuthResponse, error) { adminId, err := s.service.Authenticate(ctx, req.Token) @@ -68,7 +68,7 @@ func (s Secure) Authenticate(ctx context.Context, req domain.SecureAuthRequest) // @Produce json // @Param body body domain.SecureAuthzRequest true "Тело запроса" // @Success 200 {object} domain.SecureAuthzResponse -// @Failure 500 {object} domain.GrpcError +// @Failure 500 {object} apierrors.Error // @Router /secure/authorize [POST] func (s Secure) Authorize(ctx context.Context, req domain.SecureAuthzRequest) (*domain.SecureAuthzResponse, error) { ok, err := s.service.Authorize(ctx, req.AdminId, req.Permission) diff --git a/controller/session.go b/controller/session.go index b96027e..eb0fda6 100644 --- a/controller/session.go +++ b/controller/session.go @@ -29,8 +29,8 @@ func NewSession(service SessionService) Session { // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Param body body domain.SessionPageRequest true "Тело запроса" // @Success 200 {object} domain.SessionResponse -// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса" -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error "Невалидное тело запроса" +// @Failure 500 {object} apierrors.Error // @Router /session/all [POST] func (c Session) All(ctx context.Context, req domain.SessionPageRequest) (*domain.SessionResponse, error) { if req.Order == nil { @@ -51,8 +51,8 @@ func (c Session) All(ctx context.Context, req domain.SessionPageRequest) (*domai // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Param body body domain.RevokeRequest true "Тело запроса" // @Success 200 -// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса" -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error "Невалидное тело запроса" +// @Failure 500 {object} apierrors.Error // @Router /session/revoke [POST] func (c Session) Revoke(ctx context.Context, req domain.RevokeRequest) error { return c.service.Revoke(ctx, req.Id) diff --git a/controller/ui_settings.go b/controller/ui_settings.go index e3c67e4..b2e1e2b 100644 --- a/controller/ui_settings.go +++ b/controller/ui_settings.go @@ -31,9 +31,9 @@ func NewUiSettings(service UiSettingsService) UiSettings { // @Produce json // @Param body body domain.ClientNameRequest true "Тело запроса" // @Success 200 {object} domain.UiOauthSetting -// @Failure 400 {object} domain.GrpcError -// @Failure 401 {object} domain.GrpcError "Неизвестное название клиента" -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error +// @Failure 401 {object} apierrors.Error "Неизвестное название клиента" +// @Failure 500 {object} apierrors.Error // @Router /ui_settings/oauth [POST] func (c UiSettings) OauthSettings(ctx context.Context, req domain.ClientNameRequest) (*domain.UiOauthSetting, error) { resp, err := c.service.OauthSettings(ctx, req) diff --git a/controller/user.go b/controller/user.go index 4eb8c17..4234993 100644 --- a/controller/user.go +++ b/controller/user.go @@ -41,9 +41,9 @@ func NewUser(userService userService) User { // @Produce json // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Success 200 {object} domain.AdminUserShort -// @Failure 400 {object} domain.GrpcError "Невалидный токен" -// @Failure 404 {object} domain.GrpcError "Пользователя не существует" -// @Failure 500 {object} domain.GrpcError +// @Failure 401 {object} apierrors.Error "Невалидный токен" +// @Failure 404 {object} apierrors.Error "Пользователя не существует" +// @Failure 500 {object} apierrors.Error // @Router /user/get_profile [POST] func (u User) GetProfile(ctx context.Context, r *http.Request) (*domain.AdminUserShort, error) { adminId, err := getAdminId(r) @@ -73,8 +73,8 @@ func (u User) GetProfile(ctx context.Context, r *http.Request) (*domain.AdminUse // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Param body body domain.UsersPageRequest true "Тело запроса" // @Success 200 {object} domain.UsersResponse -// @Failure 400 {object} domain.GrpcError -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error +// @Failure 500 {object} apierrors.Error // @Router /user/get_users [POST] func (u User) GetUsers(ctx context.Context, req domain.UsersPageRequest) (*domain.UsersResponse, error) { if req.Order == nil { @@ -100,8 +100,8 @@ func (u User) GetUsers(ctx context.Context, req domain.UsersPageRequest) (*domai // @Produce json // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Success 200 {object} domain.UsersResponse -// @Failure 400 {object} domain.GrpcError -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error +// @Failure 500 {object} apierrors.Error // @Router /user/get_all_users [POST] func (u User) GetAllUsers(ctx context.Context) (*domain.UsersResponse, error) { users, err := u.userService.GetAllUsers(ctx) @@ -121,9 +121,9 @@ func (u User) GetAllUsers(ctx context.Context) (*domain.UsersResponse, error) { // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Param body body domain.CreateUserRequest true "Тело запроса" // @Success 200 {object} domain.User -// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса" -// @Failure 409 {object} domain.GrpcError "Пользователь с указанным email уже существует" -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error "Невалидное тело запроса" +// @Failure 409 {object} apierrors.Error "Пользователь с указанным email уже существует" +// @Failure 500 {object} apierrors.Error // @Router /user/create_user [POST] func (u User) CreateUser(ctx context.Context, req domain.CreateUserRequest, r *http.Request) (*domain.User, error) { adminId, err := getAdminId(r) @@ -151,10 +151,10 @@ func (u User) CreateUser(ctx context.Context, req domain.CreateUserRequest, r *h // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Param body body domain.UpdateUserRequest true "Тело запроса" // @Success 200 {object} domain.User -// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса" -// @Failure 404 {object} domain.GrpcError "Пользователь с указанным id не существует" -// @Failure 409 {object} domain.GrpcError "Пользователь с указанным email уже существует" -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error "Невалидное тело запроса" +// @Failure 404 {object} apierrors.Error "Пользователь с указанным id не существует" +// @Failure 409 {object} apierrors.Error "Пользователь с указанным email уже существует" +// @Failure 500 {object} apierrors.Error // @Router /user/update_user [POST] func (u User) UpdateUser(ctx context.Context, req domain.UpdateUserRequest, r *http.Request) (*domain.User, error) { adminId, err := getAdminId(r) @@ -186,8 +186,8 @@ func (u User) UpdateUser(ctx context.Context, req domain.UpdateUserRequest, r *h // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Param body body domain.IdentitiesRequest true "Тело запроса" // @Success 200 {object} domain.DeleteResponse -// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса" -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error "Невалидное тело запроса" +// @Failure 500 {object} apierrors.Error // @Router /user/delete_user [POST] func (u User) DeleteUser(ctx context.Context, identities domain.IdentitiesRequest, r *http.Request) (*domain.DeleteResponse, error) { adminId, err := getAdminId(r) @@ -211,8 +211,8 @@ func (u User) DeleteUser(ctx context.Context, identities domain.IdentitiesReques // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Param body body domain.IdRequest true "Тело запроса" // @Success 200 -// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса" -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error "Невалидное тело запроса" +// @Failure 500 {object} apierrors.Error // @Router /user/block_user [POST] func (u User) Block(ctx context.Context, identities domain.IdRequest, r *http.Request) error { adminId, err := getAdminId(r) @@ -234,8 +234,8 @@ func (u User) Block(ctx context.Context, identities domain.IdRequest, r *http.Re // @Produce json // @Param body body domain.IdRequest true "Тело запроса" // @Success 200 {object} domain.User -// @Failure 400 {object} domain.GrpcError "Невалидное тело запроса" -// @Failure 500 {object} domain.GrpcError +// @Failure 400 {object} apierrors.Error "Невалидное тело запроса" +// @Failure 500 {object} apierrors.Error // @Router /user/get_by_id [POST] func (u User) GetById(ctx context.Context, identities domain.IdRequest) (*domain.User, error) { return u.userService.GetById(ctx, identities.UserId) @@ -249,8 +249,8 @@ func (u User) GetById(ctx context.Context, identities domain.IdRequest) (*domain // @Param X-AUTH-ADMIN header string true "Токен администратора" // @Param body body domain.ChangePasswordRequest true "Тело запроса" // @Success 200 -// @Failure 400 {object} apierrors.Error "Невалидное тело запроса" -// @Failure 500 {object} apierrors.Error "внутренняя ошибка" +// @Failure 400 {object} apierrors.Error "Невалидное тело запроса или неверный старый пароль" +// @Failure 500 {object} apierrors.Error "Внутренняя ошибка" // @Router /user/change_password [POST] func (u User) ChangePassword(ctx context.Context, req domain.ChangePasswordRequest, r *http.Request) error { adminId, err := getAdminId(r) diff --git a/docs/swagger.json b/docs/swagger.json index e1543c0..ffff79f 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -46,19 +46,25 @@ "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "401": { "description": "Данные для авторизации не верны", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" + } + }, + "429": { + "description": "Слишком много запросов на авторизацию", + "schema": { + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -66,7 +72,7 @@ }, "/auth/login_with_oauth": { "post": { - "description": "Авторизация с получением токена администратора", + "description": "Авторизация с получением токена администратора. `errorCode: \u003cErrOauthIsMissedCode\u003e` - OAuth не настроен, `\u003cErrUnauthenticatedCode\u003e` - неверный код или неизвестный клиент", "consumes": [ "application/json" ], @@ -95,22 +101,22 @@ "$ref": "#/definitions/domain.LoginResponse" } }, + "400": { + "description": "Авторизация OAuth не настроена на сервере", + "schema": { + "$ref": "#/definitions/apierrors.Error" + } + }, "401": { "description": "Некорректный код для авторизации или неизвестное название клиента", "schema": { - "$ref": "#/definitions/domain.GrpcError" - } - }, - "412": { - "description": "Авторизация OAuth не настроена на сервере", - "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -140,18 +146,22 @@ ], "responses": { "200": { - "description": "OK" + "description": "Успешный выход", + "schema": { + "type": "object", + "additionalProperties": true + } }, "400": { "description": "Невалидный токен", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -171,6 +181,13 @@ ], "summary": "Выход по бездействию из авторизованной сессии", "parameters": [ + { + "type": "string", + "description": "Токен администратора", + "name": "X-AUTH-ADMIN", + "in": "header", + "required": true + }, { "description": "Тело запроса", "name": "body", @@ -179,29 +196,26 @@ "schema": { "$ref": "#/definitions/domain.LogoutRequest" } - }, - { - "type": "string", - "description": "Токен администратора", - "name": "X-AUTH-ADMIN", - "in": "header", - "required": true } ], "responses": { "200": { - "description": "OK" + "description": "Успешный выход", + "schema": { + "type": "object", + "additionalProperties": true + } }, "400": { "description": "Невалидный токен", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -209,6 +223,7 @@ }, "/log/all": { "post": { + "description": "`errorCode: 400` - если тело запроса невалидно", "consumes": [ "application/json" ], @@ -228,7 +243,7 @@ "required": true }, { - "description": "Тело запроса", + "description": "Тело запроса (пагинация, сортировка, фильтры)", "name": "body", "in": "body", "required": true, @@ -247,13 +262,49 @@ "400": { "description": "Невалидное тело запроса", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" + } + } + } + } + }, + "/log/download": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Download" + ], + "summary": "Скачать журнал аудита в csv", + "parameters": [ + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.AuditDownloadRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "500": { + "description": "Внутренняя ошибка сервиса ```{errorCode: -1}```", + "schema": { + "$ref": "#/definitions/apierrors.Error" } } } @@ -271,7 +322,7 @@ "tags": [ "log" ], - "summary": "Получение списка логов", + "summary": "Получение списка событий аудита", "parameters": [ { "type": "string", @@ -279,15 +330,6 @@ "name": "X-AUTH-ADMIN", "in": "header", "required": true - }, - { - "description": "Тело запроса", - "name": "body", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/domain.AuditResponse" - } } ], "responses": { @@ -300,16 +342,10 @@ } } }, - "400": { - "description": "Невалидное тело запроса", - "schema": { - "$ref": "#/definitions/domain.GrpcError" - } - }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -317,7 +353,7 @@ }, "/log/set_events": { "post": { - "description": "Всегда возвращает полный список доступных событий аудита", + "description": "Устанавливает (обновляет) набор активных событий аудита. `errorCode: \u003cUnknownAuditEventErrorCode\u003e` - если передано неизвестное событие аудита", "consumes": [ "application/json" ], @@ -327,7 +363,7 @@ "tags": [ "log" ], - "summary": "Получение списка логов", + "summary": "Установить события аудита", "parameters": [ { "type": "string", @@ -337,29 +373,36 @@ "required": true }, { - "description": "Тело запроса", + "description": "Список событий аудита для установки", "name": "body", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/domain.SetAuditEvent" + "type": "array", + "items": { + "$ref": "#/definitions/domain.SetAuditEvent" + } } } ], "responses": { "200": { - "description": "OK" + "description": "События успешно установлены", + "schema": { + "type": "object", + "additionalProperties": true + } }, "400": { - "description": "Невалидное тело запроса", + "description": "Неизвестное событие аудита", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -409,13 +452,13 @@ "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -431,7 +474,7 @@ "application/json" ], "tags": [ - "user" + "role" ], "summary": "Создать роль", "parameters": [ @@ -456,25 +499,25 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/domain.User" + "$ref": "#/definitions/domain.Role" } }, "400": { "description": "Невалидное тело запроса", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "409": { "description": "Роль с указанным именем уже существует", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -518,13 +561,38 @@ "400": { "description": "Невалидное тело запроса", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" + } + } + } + } + }, + "/role/download": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Download" + ], + "summary": "Скачать матрицу ролей в csv", + "responses": { + "200": { + "description": "OK" + }, + "500": { + "description": "Внутренняя ошибка сервиса ```{errorCode: -1}```", + "schema": { + "$ref": "#/definitions/apierrors.Error" } } } @@ -571,19 +639,19 @@ "404": { "description": "Роль с указанным id не существует", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "409": { "description": "Роль с указанным именем уже существует", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -623,7 +691,7 @@ "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -663,7 +731,7 @@ "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -709,13 +777,49 @@ "400": { "description": "Невалидное тело запроса", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" + } + } + } + } + }, + "/session/download": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Download" + ], + "summary": "Скачать список сессий в csv", + "parameters": [ + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.SessionDownloadRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "500": { + "description": "Внутренняя ошибка сервиса ```{errorCode: -1}```", + "schema": { + "$ref": "#/definitions/apierrors.Error" } } } @@ -758,13 +862,13 @@ "400": { "description": "Невалидное тело запроса", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -804,19 +908,19 @@ "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "401": { "description": "Неизвестное название клиента", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -859,13 +963,13 @@ "400": { "description": "Невалидное тело запроса", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -906,13 +1010,13 @@ "description": "OK" }, "400": { - "description": "Невалидное тело запроса", + "description": "Невалидное тело запроса или неверный старый пароль", "schema": { "$ref": "#/definitions/apierrors.Error" } }, "500": { - "description": "внутренняя ошибка", + "description": "Внутренняя ошибка", "schema": { "$ref": "#/definitions/apierrors.Error" } @@ -961,19 +1065,19 @@ "400": { "description": "Невалидное тело запроса", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "409": { "description": "Пользователь с указанным email уже существует", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -1020,13 +1124,49 @@ "400": { "description": "Невалидное тело запроса", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" + } + } + } + } + }, + "/user/download": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Download" + ], + "summary": "Скачать список пользователей в csv", + "parameters": [ + { + "description": "Тело запроса", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/domain.UsersDownloadRequest" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "500": { + "description": "Внутренняя ошибка сервиса ```{errorCode: -1}```", + "schema": { + "$ref": "#/definitions/apierrors.Error" } } } @@ -1064,13 +1204,13 @@ "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -1109,13 +1249,13 @@ "400": { "description": "Невалидное тело запроса", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -1153,13 +1293,13 @@ "400": { "description": "Невалидный токен", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -1167,7 +1307,7 @@ }, "/user/get_permissions": { "post": { - "description": "Получить все разрашения", + "description": "Получить все разрешения", "consumes": [ "application/json" ], @@ -1177,7 +1317,7 @@ "tags": [ "user" ], - "summary": "Получить все разрашения", + "summary": "Получить все разрешения", "responses": { "200": { "description": "OK", @@ -1187,6 +1327,12 @@ "$ref": "#/definitions/domain.Permission" } } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/apierrors.Error" + } } } } @@ -1220,22 +1366,22 @@ "$ref": "#/definitions/domain.AdminUserShort" } }, - "400": { + "401": { "description": "Невалидный токен", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "404": { "description": "Пользователя не существует", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -1282,13 +1428,13 @@ "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -1335,25 +1481,25 @@ "400": { "description": "Невалидное тело запроса", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "404": { "description": "Пользователь с указанным id не существует", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "409": { "description": "Пользователь с указанным email уже существует", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/domain.GrpcError" + "$ref": "#/definitions/apierrors.Error" } } } @@ -1450,6 +1596,29 @@ } } }, + "domain.AuditDownloadRequest": { + "type": "object", + "required": [ + "limit" + ], + "properties": { + "limit": { + "description": "Максимальное количество записей", + "type": "integer" + }, + "offset": { + "description": "Отступ для выборки", + "type": "integer", + "format": "int64" + }, + "order": { + "$ref": "#/definitions/domain.OrderParams" + }, + "query": { + "$ref": "#/definitions/domain.AuditQuery" + } + } + }, "domain.AuditEvent": { "type": "object", "properties": { @@ -1669,21 +1838,6 @@ } } }, - "domain.GrpcError": { - "type": "object", - "properties": { - "details": { - "type": "array", - "items": {} - }, - "errorCode": { - "type": "string" - }, - "errorMessage": { - "type": "string" - } - } - }, "domain.IdRequest": { "type": "object", "required": [ @@ -1944,6 +2098,29 @@ } } }, + "domain.SessionDownloadRequest": { + "type": "object", + "required": [ + "limit" + ], + "properties": { + "limit": { + "description": "Максимальное количество записей", + "type": "integer" + }, + "offset": { + "description": "Отступ для выборки", + "type": "integer", + "format": "int64" + }, + "order": { + "$ref": "#/definitions/domain.OrderParams" + }, + "query": { + "$ref": "#/definitions/domain.SessionQuery" + } + } + }, "domain.SessionPageRequest": { "type": "object", "required": [ @@ -2235,6 +2412,29 @@ } } }, + "domain.UsersDownloadRequest": { + "type": "object", + "required": [ + "limit" + ], + "properties": { + "limit": { + "description": "Максимальное количество записей", + "type": "integer" + }, + "offset": { + "description": "Отступ для выборки", + "type": "integer", + "format": "int64" + }, + "order": { + "$ref": "#/definitions/domain.OrderParams" + }, + "query": { + "$ref": "#/definitions/domain.UserQuery" + } + } + }, "domain.UsersPageRequest": { "type": "object", "required": [