From f65dd9c2aa81bba8a8b6203f707a3de0e152a2e1 Mon Sep 17 00:00:00 2001 From: DeniskaRediska Date: Mon, 1 Aug 2022 18:07:01 +0300 Subject: [PATCH] MSP-634 update swagger --- controller/access_list.go | 12 +- controller/application.go | 24 ++-- controller/domain.go | 12 +- controller/service.go | 20 +-- controller/token.go | 8 +- docs/docs.go | 261 ++++++++++++++++++++++++++++++-------- docs/swagger.yaml | 196 +++++++++++++++++++++------- domain/grpc_error.go | 7 + 8 files changed, 398 insertions(+), 142 deletions(-) create mode 100644 domain/grpc_error.go diff --git a/controller/access_list.go b/controller/access_list.go index bcfec1f..0a49998 100644 --- a/controller/access_list.go +++ b/controller/access_list.go @@ -33,8 +33,8 @@ func NewAccessList(service AccessListService) AccessList { // @Produce json // @Param body body domain.Identity false "идентификатор приложения" // @Success 200 {array} domain.MethodInfo "список доступности методов" -// @Failure 404 {object} structure.GrpcError -// @Failure 500 {object} structure.GrpcError +// @Failure 404 {object} domain.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /access_list/get_by_id [POST] func (c AccessList) GetById(ctx context.Context, req domain.Identity) ([]domain.MethodInfo, error) { result, err := c.service.GetById(ctx, req.Id) @@ -56,8 +56,8 @@ func (c AccessList) GetById(ctx context.Context, req domain.Identity) ([]domain. // @Produce json // @Param body body domain.AccessListSetOneRequest false "объект для настройки доступа" // @Success 200 {object} domain.AccessListSetOneResponse "количество измененных строк" -// @Failure 404 {object} structure.GrpcError -// @Failure 500 {object} structure.GrpcError +// @Failure 404 {object} domain.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /access_list/set_one [POST] func (c AccessList) SetOne(ctx context.Context, req domain.AccessListSetOneRequest) (*domain.AccessListSetOneResponse, error) { result, err := c.service.SetOne(ctx, req) @@ -79,8 +79,8 @@ func (c AccessList) SetOne(ctx context.Context, req domain.AccessListSetOneReque // @Produce json // @Param body body domain.AccessListSetListRequest false "объект настройки доступа" // @Success 200 {array} domain.MethodInfo "список доступности методов" -// @Failure 404 {object} structure.GrpcError -// @Failure 500 {object} structure.GrpcError +// @Failure 404 {object} domain.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /access_list/set_list [POST] func (c AccessList) SetList(ctx context.Context, req domain.AccessListSetListRequest) ([]domain.MethodInfo, error) { result, err := c.service.SetList(ctx, req) diff --git a/controller/application.go b/controller/application.go index c973c0c..6eb3004 100644 --- a/controller/application.go +++ b/controller/application.go @@ -36,9 +36,9 @@ func NewApplication(service ApplicationService) Application { // @Produce json // @Param body body domain.Identity true "Идентификатор приложения" // @Success 200 {object} domain.ApplicationWithTokens -// @Failure 400 {object} structure.GrpcError -// @Failure 404 {object} structure.GrpcError -// @Failure 500 {object} structure.GrpcError +// @Failure 400 {object} domain.GrpcError +// @Failure 404 {object} domain.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /application/get_application_by_id [POST] func (c Application) GetById(ctx context.Context, req domain.Identity) (*domain.ApplicationWithTokens, error) { result, err := c.service.GetById(ctx, req.Id) @@ -60,7 +60,7 @@ func (c Application) GetById(ctx context.Context, req domain.Identity) (*domain. // @Produce json // @Param body body []integer false "Массив идентификаторов приложений" // @Success 200 {array} domain.ApplicationWithTokens -// @Failure 500 {object} structure.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /application/get_applications [POST] func (c Application) GetByIdList(ctx context.Context, req []int) ([]*domain.ApplicationWithTokens, error) { return c.service.GetByIdList(ctx, req) @@ -74,7 +74,7 @@ func (c Application) GetByIdList(ctx context.Context, req []int) ([]*domain.Appl // @Produce json // @Param body body domain.Identity true "Идентификатор сервиса" // @Success 200 {array} domain.ApplicationWithTokens -// @Failure 500 {object} structure.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /application/get_applications_by_service_id [POST] func (c Application) GetByServiceId(ctx context.Context, req domain.Identity) ([]*domain.ApplicationWithTokens, error) { return c.service.GetByServiceId(ctx, req.Id) @@ -87,7 +87,7 @@ func (c Application) GetByServiceId(ctx context.Context, req domain.Identity) ([ // @Accept json // @Produce json // @Success 200 {array} domain.DomainWithService -// @Failure 500 {object} structure.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /application/get_system_tree [POST] func (c Application) GetSystemTree(ctx context.Context) ([]*domain.DomainWithService, error) { return c.service.SystemTree(ctx, domain.DefaultSystemId) @@ -101,10 +101,10 @@ func (c Application) GetSystemTree(ctx context.Context) ([]*domain.DomainWithSer // @Produce json // @Param body body domain.ApplicationCreateUpdateRequest true "Объект приложения" // @Success 200 {object} domain.ApplicationWithTokens -// @Failure 400 {object} structure.GrpcError -// @Failure 404 {object} structure.GrpcError -// @Failure 409 {object} structure.GrpcError -// @Failure 500 {object} structure.GrpcError +// @Failure 400 {object} domain.GrpcError +// @Failure 404 {object} domain.GrpcError +// @Failure 409 {object} domain.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /application/create_update_application [POST] func (c Application) CreateUpdate(ctx context.Context, req domain.ApplicationCreateUpdateRequest) (*domain.ApplicationWithTokens, error) { result, err := c.service.CreateUpdate(ctx, req) @@ -130,8 +130,8 @@ func (c Application) CreateUpdate(ctx context.Context, req domain.ApplicationCre // @Produce json // @Param body body []integer false "Массив идентификаторов приложений" // @Success 200 {object} domain.DeleteResponse -// @Failure 400 {object} structure.GrpcError -// @Failure 500 {object} structure.GrpcError +// @Failure 400 {object} domain.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /application/delete_applications [POST] func (c Application) Delete(ctx context.Context, req []int) (*domain.DeleteResponse, error) { if len(req) == 0 { diff --git a/controller/domain.go b/controller/domain.go index d74549a..75ef850 100644 --- a/controller/domain.go +++ b/controller/domain.go @@ -34,8 +34,8 @@ func NewDomain(service DomainService) Domain { // @Produce json // @Param body body domain.Identity true "Идентификатор домена" // @Success 200 {object} domain.Domain -// @Failure 404 {object} structure.GrpcError -// @Failure 500 {object} structure.GrpcError +// @Failure 404 {object} domain.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /domain/get_domain_by_id [POST] func (c Domain) GetById(ctx context.Context, req domain.Identity) (*domain.Domain, error) { result, err := c.service.GetById(ctx, req.Id) @@ -57,7 +57,7 @@ func (c Domain) GetById(ctx context.Context, req domain.Identity) (*domain.Domai // @Produce json // @Param body body integer false "Идентификатор системы" // @Success 200 {array} domain.Domain -// @Failure 500 {object} structure.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /domain/get_domains_by_system_id [POST] func (c Domain) GetBySystemId(ctx context.Context) ([]domain.Domain, error) { return c.service.GetBySystemId(ctx, domain.DefaultSystemId) @@ -71,7 +71,7 @@ func (c Domain) GetBySystemId(ctx context.Context) ([]domain.Domain, error) { // @Produce json // @Param body body domain.DomainCreateUpdateRequest true "Объект домена" // @Success 200 {object} domain.Domain -// @Failure 500 {object} structure.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /domain/create_update_domain [POST] func (c Domain) CreateUpdate(ctx context.Context, req domain.DomainCreateUpdateRequest) (*domain.Domain, error) { result, err := c.service.CreateUpdate(ctx, req, domain.DefaultSystemId) @@ -97,8 +97,8 @@ func (c Domain) CreateUpdate(ctx context.Context, req domain.DomainCreateUpdateR // @Produce json // @Param body body []integer false "Массив идентификаторов доменов" // @Success 200 {object} domain.DeleteResponse -// @Failure 400 {object} structure.GrpcError -// @Failure 500 {object} structure.GrpcError +// @Failure 400 {object} domain.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /domain/delete_domains [POST] func (c Domain) Delete(ctx context.Context, req []int) (*domain.DeleteResponse, error) { if len(req) == 0 { diff --git a/controller/service.go b/controller/service.go index 2aaa3ad..f60a6fd 100644 --- a/controller/service.go +++ b/controller/service.go @@ -35,8 +35,8 @@ func NewService(service ServiceService) Service { // @Produce json // @Param body body domain.Identity true "Идентификатор сервиса" // @Success 200 {object} domain.Service -// @Failure 404 {object} structure.GrpcError -// @Failure 500 {object} structure.GrpcError +// @Failure 404 {object} domain.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /service/get_service_by_id [POST] func (c Service) GetById(ctx context.Context, req domain.Identity) (*domain.Service, error) { result, err := c.service.GetById(ctx, req.Id) @@ -58,7 +58,7 @@ func (c Service) GetById(ctx context.Context, req domain.Identity) (*domain.Serv // @Produce json // @Param body body []integer false "Массив идентификаторов сервисов" // @Success 200 {array} domain.Service -// @Failure 500 {object} structure.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /service/get_service [POST] func (c Service) Get(ctx context.Context, req []int) ([]domain.Service, error) { return c.service.GetByIdList(ctx, req) @@ -72,7 +72,7 @@ func (c Service) Get(ctx context.Context, req []int) ([]domain.Service, error) { // @Produce json // @Param body body domain.Identity true "Идентификатор домена" // @Success 200 {array} domain.Service -// @Failure 500 {object} structure.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /service/get_services_by_domain_id [POST] func (c Service) GetByDomainId(ctx context.Context, req domain.Identity) ([]domain.Service, error) { return c.service.GetByDomainId(ctx, req.Id) @@ -86,10 +86,10 @@ func (c Service) GetByDomainId(ctx context.Context, req domain.Identity) ([]doma // @Produce json // @Param body body domain.ServiceCreateUpdateRequest true "Объект сервиса" // @Success 200 {object} domain.Service -// @Failure 400 {object} structure.GrpcError -// @Failure 404 {object} structure.GrpcError -// @Failure 409 {object} structure.GrpcError -// @Failure 500 {object} structure.GrpcError +// @Failure 400 {object} domain.GrpcError +// @Failure 404 {object} domain.GrpcError +// @Failure 409 {object} domain.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /service/create_update_service [POST] func (c Service) CreateUpdate(ctx context.Context, req domain.ServiceCreateUpdateRequest) (*domain.Service, error) { result, err := c.service.CreateUpdate(ctx, req) @@ -115,8 +115,8 @@ func (c Service) CreateUpdate(ctx context.Context, req domain.ServiceCreateUpdat // @Produce json // @Param body body []integer true "Массив идентификаторов сервисов" // @Success 200 {object} domain.DeleteResponse -// @Failure 400 {object} structure.GrpcError -// @Failure 500 {object} structure.GrpcError +// @Failure 400 {object} domain.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /service/delete_service [POST] func (c Service) Delete(ctx context.Context, req []int) (*domain.DeleteResponse, error) { if len(req) == 0 { diff --git a/controller/token.go b/controller/token.go index 33b8d39..81ff848 100644 --- a/controller/token.go +++ b/controller/token.go @@ -34,7 +34,7 @@ func NewToken(service ITokenService) Token { // @Produce json // @Param body body domain.Identity true "Идентификатор приложения" // @Success 200 {array} entity.Token -// @Failure 500 {object} structure.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /token/get_tokens_by_app_id [POST] func (c Token) GetByAppId(ctx context.Context, req domain.Identity) ([]domain.Token, error) { return c.service.GetByAppId(ctx, req.Id) @@ -48,7 +48,7 @@ func (c Token) GetByAppId(ctx context.Context, req domain.Identity) ([]domain.To // @Produce json // @Param body body domain.TokenCreateRequest true "Объект создания токена" // @Success 200 {object} domain.ApplicationWithTokens -// @Failure 500 {object} structure.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /token/create_token [POST] func (c Token) Create(ctx context.Context, req domain.TokenCreateRequest) (*domain.ApplicationWithTokens, error) { result, err := c.service.Create(ctx, req) @@ -74,7 +74,7 @@ func (c Token) Create(ctx context.Context, req domain.TokenCreateRequest) (*doma // @Produce json // @Param body body domain.TokenRevokeRequest true "Объект отзыва токенов" // @Success 200 {object} domain.ApplicationWithTokens -// @Failure 500 {object} structure.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /token/revoke_tokens [POST] func (c Token) Revoke(ctx context.Context, req domain.TokenRevokeRequest) (*domain.ApplicationWithTokens, error) { return c.service.Revoke(ctx, req) @@ -88,7 +88,7 @@ func (c Token) Revoke(ctx context.Context, req domain.TokenRevokeRequest) (*doma // @Produce json // @Param body body domain.Identity true "Идентификатор приложения" // @Success 200 {object} domain.DeleteResponse -// @Failure 500 {object} structure.GrpcError +// @Failure 500 {object} domain.GrpcError // @Router /token/revoke_tokens_for_app [POST] func (c Token) RevokeForApp(ctx context.Context, req domain.Identity) (*domain.DeleteResponse, error) { return c.service.RevokeByAppId(ctx, req.Id) diff --git a/docs/docs.go b/docs/docs.go index 37da07e..6a77f69 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -55,13 +55,13 @@ var doc = `{ "404": { "description": "Not Found", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -103,13 +103,13 @@ var doc = `{ "404": { "description": "Not Found", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -148,13 +148,13 @@ var doc = `{ "404": { "description": "Not Found", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -194,25 +194,25 @@ var doc = `{ "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "404": { "description": "Not Found", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "409": { "description": "Conflict", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -254,13 +254,13 @@ var doc = `{ "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -300,19 +300,19 @@ var doc = `{ "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "404": { "description": "Not Found", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -357,7 +357,7 @@ var doc = `{ "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -400,7 +400,7 @@ var doc = `{ "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -432,7 +432,7 @@ var doc = `{ "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -472,7 +472,7 @@ var doc = `{ "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -514,13 +514,13 @@ var doc = `{ "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -560,13 +560,13 @@ var doc = `{ "404": { "description": "Not Found", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -608,7 +608,93 @@ var doc = `{ "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$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.AuthenticateRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.AuthenticateResponse" + } + } + }, + "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.AuthorizeRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/domain.AuthorizeResponse" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/domain.GrpcError" } } } @@ -648,25 +734,25 @@ var doc = `{ "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "404": { "description": "Not Found", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "409": { "description": "Conflict", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -709,13 +795,13 @@ var doc = `{ "400": { "description": "Bad Request", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -760,7 +846,7 @@ var doc = `{ "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -800,13 +886,13 @@ var doc = `{ "404": { "description": "Not Found", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } }, "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -849,7 +935,7 @@ var doc = `{ "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -889,7 +975,7 @@ var doc = `{ "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -932,7 +1018,7 @@ var doc = `{ "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -972,7 +1058,7 @@ var doc = `{ "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -1012,7 +1098,7 @@ var doc = `{ "500": { "description": "Internal Server Error", "schema": { - "$ref": "#/definitions/structure.GrpcError" + "$ref": "#/definitions/domain.GrpcError" } } } @@ -1158,6 +1244,71 @@ var doc = `{ } } }, + "domain.AuthData": { + "type": "object", + "properties": { + "applicationId": { + "type": "integer" + }, + "domainId": { + "type": "integer" + }, + "serviceId": { + "type": "integer" + }, + "systemId": { + "type": "integer" + } + } + }, + "domain.AuthenticateRequest": { + "type": "object", + "required": [ + "token" + ], + "properties": { + "token": { + "type": "string" + } + } + }, + "domain.AuthenticateResponse": { + "type": "object", + "properties": { + "authData": { + "$ref": "#/definitions/domain.AuthData" + }, + "authenticated": { + "type": "boolean" + }, + "errorReason": { + "type": "string" + } + } + }, + "domain.AuthorizeRequest": { + "type": "object", + "required": [ + "applicationId", + "endpoint" + ], + "properties": { + "applicationId": { + "type": "integer" + }, + "endpoint": { + "type": "string" + } + } + }, + "domain.AuthorizeResponse": { + "type": "object", + "properties": { + "authorized": { + "type": "boolean" + } + } + }, "domain.DeleteResponse": { "type": "object", "properties": { @@ -1226,6 +1377,23 @@ var doc = `{ } } }, + "domain.GrpcError": { + "type": "object", + "properties": { + "details": { + "type": "array", + "items": { + "type": "object" + } + }, + "errorCode": { + "type": "string" + }, + "errorMessage": { + "type": "string" + } + } + }, "domain.Identity": { "type": "object", "required": [ @@ -1376,23 +1544,6 @@ var doc = `{ "type": "string" } } - }, - "structure.GrpcError": { - "type": "object", - "properties": { - "details": { - "type": "array", - "items": { - "type": "object" - } - }, - "errorCode": { - "type": "string" - }, - "errorMessage": { - "type": "string" - } - } } } }` diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 0360d05..1a3b190 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -91,6 +91,48 @@ definitions: $ref: '#/definitions/domain.Token' type: array type: object + domain.AuthData: + properties: + applicationId: + type: integer + domainId: + type: integer + serviceId: + type: integer + systemId: + type: integer + type: object + domain.AuthenticateRequest: + properties: + token: + type: string + required: + - token + type: object + domain.AuthenticateResponse: + properties: + authData: + $ref: '#/definitions/domain.AuthData' + authenticated: + type: boolean + errorReason: + type: string + type: object + domain.AuthorizeRequest: + properties: + applicationId: + type: integer + endpoint: + type: string + required: + - applicationId + - endpoint + type: object + domain.AuthorizeResponse: + properties: + authorized: + type: boolean + type: object domain.DeleteResponse: properties: deleted: @@ -135,6 +177,17 @@ definitions: $ref: '#/definitions/domain.ServiceWithApps' type: array type: object + domain.GrpcError: + properties: + details: + items: + type: object + type: array + errorCode: + type: string + errorMessage: + type: string + type: object domain.Identity: properties: id: @@ -233,17 +286,6 @@ definitions: token: type: string type: object - structure.GrpcError: - properties: - details: - items: - type: object - type: array - errorCode: - type: string - errorMessage: - type: string - type: object host: localhost:9000 info: contact: {} @@ -277,11 +319,11 @@ paths: "404": description: Not Found schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Получить список доступности методов для приложения tags: - accessList @@ -309,11 +351,11 @@ paths: "404": description: Not Found schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Настроить доступность списка методов для приложения tags: - accessList @@ -338,11 +380,11 @@ paths: "404": description: Not Found schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Настроить доступность метода для приложения tags: - accessList @@ -369,19 +411,19 @@ paths: "400": description: Bad Request schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "404": description: Not Found schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "409": description: Conflict schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Создать/обновить приложение tags: - application @@ -409,11 +451,11 @@ paths: "400": description: Bad Request schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Удалить приложения tags: - application @@ -439,15 +481,15 @@ paths: "400": description: Bad Request schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "404": description: Not Found schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Получить приложение по идентификатору tags: - application @@ -476,7 +518,7 @@ paths: "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Получить список приложений tags: - application @@ -504,7 +546,7 @@ paths: "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Получить список приложений по идентификатору сервиса tags: - application @@ -525,7 +567,7 @@ paths: "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Метод получения системного дерева tags: - application @@ -552,7 +594,7 @@ paths: "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Создать/обновить домен tags: - domain @@ -580,11 +622,11 @@ paths: "400": description: Bad Request schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Удаление доменов tags: - domain @@ -610,11 +652,11 @@ paths: "404": description: Not Found schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Получить домен по идентификатору tags: - domain @@ -641,10 +683,66 @@ paths: "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Получить домены по идентификатору системы tags: - domain + /secure/authenticate: + post: + consumes: + - application/json + description: Проверяет наличие токена в системе, + parameters: + - description: Тело запроса + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.AuthenticateRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/domain.AuthenticateResponse' + type: array + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.GrpcError' + summary: Метод аутентификации токена + tags: + - secure + /secure/authorize: + post: + consumes: + - application/json + description: Проверяет доступ приложения к запрашиваемому ендпоинту + parameters: + - description: Тело запрос + in: body + name: body + required: true + schema: + $ref: '#/definitions/domain.AuthorizeRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/domain.AuthorizeResponse' + type: array + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/domain.GrpcError' + summary: Метод авторизации приложения + tags: + - secure /service/create_update_service: post: consumes: @@ -668,19 +766,19 @@ paths: "400": description: Bad Request schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "404": description: Not Found schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "409": description: Conflict schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Создать/обновить сервис tags: - service @@ -709,11 +807,11 @@ paths: "400": description: Bad Request schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Удалить сервисы tags: - service @@ -742,7 +840,7 @@ paths: "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Получить список сервисов tags: - service @@ -768,11 +866,11 @@ paths: "404": description: Not Found schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Получить сервис по идентификатору tags: - service @@ -800,7 +898,7 @@ paths: "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Получить список сервисов по идентификатору домена tags: - service @@ -826,7 +924,7 @@ paths: "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Создать токен tags: - token @@ -854,7 +952,7 @@ paths: "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Получить токены по идентификатору приложения tags: - token @@ -880,7 +978,7 @@ paths: "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Отозвать токены tags: - token @@ -907,7 +1005,7 @@ paths: "500": description: Internal Server Error schema: - $ref: '#/definitions/structure.GrpcError' + $ref: '#/definitions/domain.GrpcError' summary: Отозвать токены для приложения tags: - token diff --git a/domain/grpc_error.go b/domain/grpc_error.go new file mode 100644 index 0000000..7bb2cfa --- /dev/null +++ b/domain/grpc_error.go @@ -0,0 +1,7 @@ +package domain + +type GrpcError struct { + ErrorMessage string `json:"errorMessage"` + ErrorCode string `json:"errorCode"` + Details []interface{} `json:"details"` +}