diff --git a/development-kit/pkg/usecases/auth/auth_test.go b/development-kit/pkg/usecases/auth/auth_test.go index 1a329c64f..732e3ca2e 100644 --- a/development-kit/pkg/usecases/auth/auth_test.go +++ b/development-kit/pkg/usecases/auth/auth_test.go @@ -343,8 +343,7 @@ func TestNewValidateUniqueFromReadCloser(t *testing.T) { func TestNewPasswordFromReadCloser(t *testing.T) { t.Run("should return required value when valid password", func(t *testing.T) { - bytes, _ := json.Marshal("") - readCloser := ioutil.NopCloser(strings.NewReader(string(bytes))) + readCloser := ioutil.NopCloser(strings.NewReader("")) useCases := NewAuthUseCases() _, err := useCases.NewPasswordFromReadCloser(readCloser) @@ -352,7 +351,7 @@ func TestNewPasswordFromReadCloser(t *testing.T) { assert.Equal(t, "cannot be blank", err.Error()) }) t.Run("should return not valid length when valid password", func(t *testing.T) { - bytes, _ := json.Marshal("@tEst12") + bytes, _ := json.Marshal("@t3st") readCloser := ioutil.NopCloser(strings.NewReader(string(bytes))) useCases := NewAuthUseCases() @@ -394,7 +393,7 @@ func TestNewPasswordFromReadCloser(t *testing.T) { useCases := NewAuthUseCases() password, err := useCases.NewPasswordFromReadCloser(readCloser) assert.NoError(t, err) - assert.Equal(t, "@t33sstEE", password) + assert.Equal(t, "\"@t33sstEE\"", password) }) t.Run("should return error when parsing invalid data", func(t *testing.T) { useCases := NewAuthUseCases() diff --git a/horusec-auth/docs/docs.go b/horusec-auth/docs/docs.go index e515c7235..0279106a9 100644 --- a/horusec-auth/docs/docs.go +++ b/horusec-auth/docs/docs.go @@ -38,11 +38,199 @@ var doc = `{ "url": "https://github.com/ZupIT/horusec", "email": "horusec@zup.com.br" }, + "license": {}, "version": "{{.Version}}" }, "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { + "/api/account/change-password": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "change password!", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "change-password", + "parameters": [ + { + "description": "new password", + "name": "password", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "NO CONTENT", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "400": { + "description": "BAD REQUEST", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "401": { + "description": "UNAUTHORIZED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { + "description": "INTERNAL SERVER ERROR", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/account/create-account": { + "post": { + "description": "Create a new account!", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "create-account", + "parameters": [ + { + "description": "create account info", + "name": "CreateAccount", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.CreateAccount" + } + } + ], + "responses": { + "201": { + "description": "STATUS CREATED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "400": { + "description": "BAD REQUEST", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { + "description": "INTERNAL SERVER ERROR", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, "/api/account/create-account-from-keycloak": { "post": { "description": "Create a new account with keycloak data!", @@ -55,21 +243,447 @@ var doc = `{ "tags": [ "Account" ], - "operationId": "create-account-keycloak", + "operationId": "create-account-keycloak", + "parameters": [ + { + "description": "keycloak token info", + "name": "KeycloakToken", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.KeycloakToken" + } + } + ], + "responses": { + "200": { + "description": "STATUS OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "$ref": "#/definitions/dto.CreateAccountFromKeycloakResponse" + } + } + } + ] + } + }, + "201": { + "description": "STATUS CREATED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "400": { + "description": "BAD REQUEST", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { + "description": "INTERNAL SERVER ERROR", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/account/delete": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Delete account and all permissions!", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "delete-account", + "responses": { + "204": { + "description": "NO CONTENT", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "401": { + "description": "UNAUTHORIZED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { + "description": "INTERNAL SERVER ERROR", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/account/logout": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "logout!", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "logout", + "responses": { + "200": { + "description": "NO CONTENT", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "401": { + "description": "UNAUTHORIZED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { + "description": "INTERNAL SERVER ERROR", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/account/renew-token": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "renew token!", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "renew-token", + "parameters": [ + { + "description": "refresh token", + "name": "refreshToken", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "400": { + "description": "BAD REQUEST", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "401": { + "description": "UNAUTHORIZED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/account/send-code": { + "post": { + "description": "send reset password code!", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "reset-password-code", + "parameters": [ + { + "description": "reset password email info", + "name": "EmailData", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.EmailData" + } + } + ], + "responses": { + "204": { + "description": "NO CONTENT", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "400": { + "description": "BAD REQUEST", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { + "description": "INTERNAL SERVER ERROR", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/account/update": { + "patch": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Update account username and/or email", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "update-account", "parameters": [ { - "description": "keycloak token info", - "name": "KeycloakToken", + "description": "update account info", + "name": "UpdateAccount", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/account.KeycloakToken" + "$ref": "#/definitions/dto.UpdateAccount" } } ], "responses": { "200": { - "description": "STATUS OK", + "description": "OK", "schema": { "allOf": [ { @@ -79,15 +693,79 @@ var doc = `{ "type": "object", "properties": { "content": { - "$ref": "#/definitions/account.CreateAccountFromKeycloakResponse" + "type": "string" } } } ] } }, - "201": { - "description": "STATUS CREATED", + "401": { + "description": "UNAUTHORIZED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { + "description": "INTERNAL SERVER ERROR", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/account/validate-code": { + "post": { + "description": "validate reset password code!", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "validate-password-code", + "parameters": [ + { + "description": "reset password data info", + "name": "ResetCodeData", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.ResetCodeData" + } + } + ], + "responses": { + "204": { + "description": "NO CONTENT", "schema": { "allOf": [ { @@ -122,6 +800,24 @@ var doc = `{ ] } }, + "401": { + "description": "UNAUTHORIZED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, "500": { "description": "INTERNAL SERVER ERROR", "schema": { @@ -143,9 +839,9 @@ var doc = `{ } } }, - "/api/auth/account-id": { + "/api/account/validate/{accountID}": { "get": { - "description": "get account by token and auth type!", + "description": "validate email!", "consumes": [ "application/json" ], @@ -153,12 +849,21 @@ var doc = `{ "application/json" ], "tags": [ - "Auth" + "Account" + ], + "operationId": "validate-email", + "parameters": [ + { + "type": "string", + "description": "accountID of the account", + "name": "accountID", + "in": "path", + "required": true + } ], - "operationId": "get account id", "responses": { "200": { - "description": "STATUS OK", + "description": "OK", "schema": { "allOf": [ { @@ -176,6 +881,24 @@ var doc = `{ } }, "400": { + "description": "BAD REQUEST", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { "description": "INTERNAL SERVER ERROR", "schema": { "allOf": [ @@ -196,9 +919,9 @@ var doc = `{ } } }, - "/api/auth/authenticate": { + "/api/account/verify-already-used": { "post": { - "description": "authenticate login by type!", + "description": "Verify if email and username already in use!", "consumes": [ "application/json" ], @@ -206,23 +929,23 @@ var doc = `{ "application/json" ], "tags": [ - "Auth" + "Account" ], - "operationId": "authenticate login", + "operationId": "validate-unique", "parameters": [ { - "description": "auth info", - "name": "Credentials", + "description": "validate unique info", + "name": "ValidateUnique", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/auth.Credentials" + "$ref": "#/definitions/dto.ValidateUnique" } } ], "responses": { - "200": { - "description": "STATUS OK", + "201": { + "description": "STATUS CREATED", "schema": { "allOf": [ { @@ -257,24 +980,6 @@ var doc = `{ ] } }, - "403": { - "description": "STATUS FORBIDDEN", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/http.Response" - }, - { - "type": "object", - "properties": { - "content": { - "type": "string" - } - } - } - ] - } - }, "500": { "description": "INTERNAL SERVER ERROR", "schema": { @@ -296,9 +1001,9 @@ var doc = `{ } } }, - "/api/auth/authorize": { + "/api/auth/authenticate": { "post": { - "description": "verify if request is valid!", + "description": "authenticate login by type!", "consumes": [ "application/json" ], @@ -308,15 +1013,15 @@ var doc = `{ "tags": [ "Auth" ], - "operationId": "authenticate request", + "operationId": "authenticate login", "parameters": [ { - "description": "authorization data", - "name": "AuthorizationData", + "description": "auth info", + "name": "Credentials", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/auth.AuthorizationData" + "$ref": "#/definitions/dto.Credentials" } } ], @@ -394,24 +1099,6 @@ var doc = `{ "responses": { "200": { "description": "STATUS OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/http.Response" - }, - { - "type": "object", - "properties": { - "content": { - "$ref": "#/definitions/auth.ConfigAuth" - } - } - } - ] - } - }, - "400": { - "description": "BAD REQUEST", "schema": { "allOf": [ { @@ -486,7 +1173,21 @@ var doc = `{ } }, "definitions": { - "account.CreateAccountFromKeycloakResponse": { + "dto.CreateAccount": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "dto.CreateAccountFromKeycloakResponse": { "type": "object", "properties": { "accountID": { @@ -503,49 +1204,62 @@ var doc = `{ } } }, - "account.KeycloakToken": { + "dto.Credentials": { "type": "object", "properties": { - "accessToken": { + "otp": { + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { "type": "string" } } }, - "auth.AuthorizationData": { + "dto.EmailData": { "type": "object", "properties": { - "companyID": { + "email": { "type": "string" - }, - "repositoryID": { + } + } + }, + "dto.KeycloakToken": { + "type": "object", + "properties": { + "accessToken": { "type": "string" - }, - "role": { + } + } + }, + "dto.ResetCodeData": { + "type": "object", + "properties": { + "code": { "type": "string" }, - "token": { + "email": { "type": "string" } } }, - "auth.ConfigAuth": { + "dto.UpdateAccount": { "type": "object", "properties": { - "applicationAdminEnable": { - "type": "boolean" + "email": { + "type": "string" }, - "authType": { + "username": { "type": "string" } } }, - "auth.Credentials": { + "dto.ValidateUnique": { "type": "object", "properties": { - "otp": { - "type": "string" - }, - "password": { + "email": { "type": "string" }, "username": { diff --git a/horusec-auth/docs/swagger.json b/horusec-auth/docs/swagger.json index 317bd2fce..8452baae8 100644 --- a/horusec-auth/docs/swagger.json +++ b/horusec-auth/docs/swagger.json @@ -8,9 +8,197 @@ "name": "Horusec", "url": "https://github.com/ZupIT/horusec", "email": "horusec@zup.com.br" - } + }, + "license": {} }, "paths": { + "/api/account/change-password": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "change password!", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "change-password", + "parameters": [ + { + "description": "new password", + "name": "password", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "NO CONTENT", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "400": { + "description": "BAD REQUEST", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "401": { + "description": "UNAUTHORIZED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { + "description": "INTERNAL SERVER ERROR", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/account/create-account": { + "post": { + "description": "Create a new account!", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "create-account", + "parameters": [ + { + "description": "create account info", + "name": "CreateAccount", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.CreateAccount" + } + } + ], + "responses": { + "201": { + "description": "STATUS CREATED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "400": { + "description": "BAD REQUEST", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { + "description": "INTERNAL SERVER ERROR", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, "/api/account/create-account-from-keycloak": { "post": { "description": "Create a new account with keycloak data!", @@ -23,21 +211,447 @@ "tags": [ "Account" ], - "operationId": "create-account-keycloak", + "operationId": "create-account-keycloak", + "parameters": [ + { + "description": "keycloak token info", + "name": "KeycloakToken", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.KeycloakToken" + } + } + ], + "responses": { + "200": { + "description": "STATUS OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "$ref": "#/definitions/dto.CreateAccountFromKeycloakResponse" + } + } + } + ] + } + }, + "201": { + "description": "STATUS CREATED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "400": { + "description": "BAD REQUEST", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { + "description": "INTERNAL SERVER ERROR", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/account/delete": { + "delete": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Delete account and all permissions!", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "delete-account", + "responses": { + "204": { + "description": "NO CONTENT", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "401": { + "description": "UNAUTHORIZED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { + "description": "INTERNAL SERVER ERROR", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/account/logout": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "logout!", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "logout", + "responses": { + "200": { + "description": "NO CONTENT", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "401": { + "description": "UNAUTHORIZED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { + "description": "INTERNAL SERVER ERROR", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/account/renew-token": { + "post": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "renew token!", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "renew-token", + "parameters": [ + { + "description": "refresh token", + "name": "refreshToken", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "400": { + "description": "BAD REQUEST", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "401": { + "description": "UNAUTHORIZED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/account/send-code": { + "post": { + "description": "send reset password code!", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "reset-password-code", + "parameters": [ + { + "description": "reset password email info", + "name": "EmailData", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.EmailData" + } + } + ], + "responses": { + "204": { + "description": "NO CONTENT", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "400": { + "description": "BAD REQUEST", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { + "description": "INTERNAL SERVER ERROR", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/account/update": { + "patch": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Update account username and/or email", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "update-account", "parameters": [ { - "description": "keycloak token info", - "name": "KeycloakToken", + "description": "update account info", + "name": "UpdateAccount", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/account.KeycloakToken" + "$ref": "#/definitions/dto.UpdateAccount" } } ], "responses": { "200": { - "description": "STATUS OK", + "description": "OK", "schema": { "allOf": [ { @@ -47,15 +661,79 @@ "type": "object", "properties": { "content": { - "$ref": "#/definitions/account.CreateAccountFromKeycloakResponse" + "type": "string" } } } ] } }, - "201": { - "description": "STATUS CREATED", + "401": { + "description": "UNAUTHORIZED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { + "description": "INTERNAL SERVER ERROR", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + } + } + } + }, + "/api/account/validate-code": { + "post": { + "description": "validate reset password code!", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Account" + ], + "operationId": "validate-password-code", + "parameters": [ + { + "description": "reset password data info", + "name": "ResetCodeData", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.ResetCodeData" + } + } + ], + "responses": { + "204": { + "description": "NO CONTENT", "schema": { "allOf": [ { @@ -90,6 +768,24 @@ ] } }, + "401": { + "description": "UNAUTHORIZED", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, "500": { "description": "INTERNAL SERVER ERROR", "schema": { @@ -111,9 +807,9 @@ } } }, - "/api/auth/account-id": { + "/api/account/validate/{accountID}": { "get": { - "description": "get account by token and auth type!", + "description": "validate email!", "consumes": [ "application/json" ], @@ -121,12 +817,21 @@ "application/json" ], "tags": [ - "Auth" + "Account" + ], + "operationId": "validate-email", + "parameters": [ + { + "type": "string", + "description": "accountID of the account", + "name": "accountID", + "in": "path", + "required": true + } ], - "operationId": "get account id", "responses": { "200": { - "description": "STATUS OK", + "description": "OK", "schema": { "allOf": [ { @@ -144,6 +849,24 @@ } }, "400": { + "description": "BAD REQUEST", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/http.Response" + }, + { + "type": "object", + "properties": { + "content": { + "type": "string" + } + } + } + ] + } + }, + "500": { "description": "INTERNAL SERVER ERROR", "schema": { "allOf": [ @@ -164,9 +887,9 @@ } } }, - "/api/auth/authenticate": { + "/api/account/verify-already-used": { "post": { - "description": "authenticate login by type!", + "description": "Verify if email and username already in use!", "consumes": [ "application/json" ], @@ -174,23 +897,23 @@ "application/json" ], "tags": [ - "Auth" + "Account" ], - "operationId": "authenticate login", + "operationId": "validate-unique", "parameters": [ { - "description": "auth info", - "name": "Credentials", + "description": "validate unique info", + "name": "ValidateUnique", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/auth.Credentials" + "$ref": "#/definitions/dto.ValidateUnique" } } ], "responses": { - "200": { - "description": "STATUS OK", + "201": { + "description": "STATUS CREATED", "schema": { "allOf": [ { @@ -225,24 +948,6 @@ ] } }, - "403": { - "description": "STATUS FORBIDDEN", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/http.Response" - }, - { - "type": "object", - "properties": { - "content": { - "type": "string" - } - } - } - ] - } - }, "500": { "description": "INTERNAL SERVER ERROR", "schema": { @@ -264,9 +969,9 @@ } } }, - "/api/auth/authorize": { + "/api/auth/authenticate": { "post": { - "description": "verify if request is valid!", + "description": "authenticate login by type!", "consumes": [ "application/json" ], @@ -276,15 +981,15 @@ "tags": [ "Auth" ], - "operationId": "authenticate request", + "operationId": "authenticate login", "parameters": [ { - "description": "authorization data", - "name": "AuthorizationData", + "description": "auth info", + "name": "Credentials", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/auth.AuthorizationData" + "$ref": "#/definitions/dto.Credentials" } } ], @@ -362,24 +1067,6 @@ "responses": { "200": { "description": "STATUS OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/http.Response" - }, - { - "type": "object", - "properties": { - "content": { - "$ref": "#/definitions/auth.ConfigAuth" - } - } - } - ] - } - }, - "400": { - "description": "BAD REQUEST", "schema": { "allOf": [ { @@ -454,7 +1141,21 @@ } }, "definitions": { - "account.CreateAccountFromKeycloakResponse": { + "dto.CreateAccount": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "dto.CreateAccountFromKeycloakResponse": { "type": "object", "properties": { "accountID": { @@ -471,49 +1172,62 @@ } } }, - "account.KeycloakToken": { + "dto.Credentials": { "type": "object", "properties": { - "accessToken": { + "otp": { + "type": "string" + }, + "password": { + "type": "string" + }, + "username": { "type": "string" } } }, - "auth.AuthorizationData": { + "dto.EmailData": { "type": "object", "properties": { - "companyID": { + "email": { "type": "string" - }, - "repositoryID": { + } + } + }, + "dto.KeycloakToken": { + "type": "object", + "properties": { + "accessToken": { "type": "string" - }, - "role": { + } + } + }, + "dto.ResetCodeData": { + "type": "object", + "properties": { + "code": { "type": "string" }, - "token": { + "email": { "type": "string" } } }, - "auth.ConfigAuth": { + "dto.UpdateAccount": { "type": "object", "properties": { - "applicationAdminEnable": { - "type": "boolean" + "email": { + "type": "string" }, - "authType": { + "username": { "type": "string" } } }, - "auth.Credentials": { + "dto.ValidateUnique": { "type": "object", "properties": { - "otp": { - "type": "string" - }, - "password": { + "email": { "type": "string" }, "username": { diff --git a/horusec-auth/docs/swagger.yaml b/horusec-auth/docs/swagger.yaml index 06293f447..003aa596d 100644 --- a/horusec-auth/docs/swagger.yaml +++ b/horusec-auth/docs/swagger.yaml @@ -13,7 +13,16 @@ # limitations under the License. definitions: - account.CreateAccountFromKeycloakResponse: + dto.CreateAccount: + properties: + email: + type: string + password: + type: string + username: + type: string + type: object + dto.CreateAccountFromKeycloakResponse: properties: accountID: type: string @@ -24,34 +33,42 @@ definitions: username: type: string type: object - account.KeycloakToken: + dto.Credentials: properties: - accessToken: + otp: + type: string + password: + type: string + username: type: string type: object - auth.AuthorizationData: + dto.EmailData: properties: - companyID: + email: type: string - repositoryID: + type: object + dto.KeycloakToken: + properties: + accessToken: type: string - role: + type: object + dto.ResetCodeData: + properties: + code: type: string - token: + email: type: string type: object - auth.ConfigAuth: + dto.UpdateAccount: properties: - applicationAdminEnable: - type: boolean - authType: + email: + type: string + username: type: string type: object - auth.Credentials: + dto.ValidateUnique: properties: - otp: - type: string - password: + email: type: string username: type: string @@ -71,9 +88,111 @@ info: name: Horusec url: https://github.com/ZupIT/horusec description: Service of Horusec. + license: {} termsOfService: http://swagger.io/terms/ title: Horusec-Auth paths: + /api/account/change-password: + post: + consumes: + - application/json + description: change password! + operationId: change-password + parameters: + - description: new password + in: body + name: password + required: true + schema: + type: string + produces: + - application/json + responses: + "204": + description: NO CONTENT + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "400": + description: BAD REQUEST + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "401": + description: UNAUTHORIZED + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "500": + description: INTERNAL SERVER ERROR + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + security: + - ApiKeyAuth: [] + tags: + - Account + /api/account/create-account: + post: + consumes: + - application/json + description: Create a new account! + operationId: create-account + parameters: + - description: create account info + in: body + name: CreateAccount + required: true + schema: + $ref: '#/definitions/dto.CreateAccount' + produces: + - application/json + responses: + "201": + description: STATUS CREATED + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "400": + description: BAD REQUEST + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "500": + description: INTERNAL SERVER ERROR + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + tags: + - Account /api/account/create-account-from-keycloak: post: consumes: @@ -86,7 +205,7 @@ paths: name: KeycloakToken required: true schema: - $ref: '#/definitions/account.KeycloakToken' + $ref: '#/definitions/dto.KeycloakToken' produces: - application/json responses: @@ -97,7 +216,7 @@ paths: - $ref: '#/definitions/http.Response' - properties: content: - $ref: '#/definitions/account.CreateAccountFromKeycloakResponse' + $ref: '#/definitions/dto.CreateAccountFromKeycloakResponse' type: object "201": description: STATUS CREATED @@ -128,17 +247,57 @@ paths: type: object tags: - Account - /api/auth/account-id: - get: + /api/account/delete: + delete: + consumes: + - application/json + description: Delete account and all permissions! + operationId: delete-account + produces: + - application/json + responses: + "204": + description: NO CONTENT + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "401": + description: UNAUTHORIZED + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "500": + description: INTERNAL SERVER ERROR + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + security: + - ApiKeyAuth: [] + tags: + - Account + /api/account/logout: + post: consumes: - application/json - description: get account by token and auth type! - operationId: get account id + description: logout! + operationId: logout produces: - application/json responses: "200": - description: STATUS OK + description: NO CONTENT schema: allOf: - $ref: '#/definitions/http.Response' @@ -146,7 +305,16 @@ paths: content: type: string type: object - "400": + "401": + description: UNAUTHORIZED + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "500": description: INTERNAL SERVER ERROR schema: allOf: @@ -155,26 +323,75 @@ paths: content: type: string type: object + security: + - ApiKeyAuth: [] tags: - - Auth - /api/auth/authenticate: + - Account + /api/account/renew-token: post: consumes: - application/json - description: authenticate login by type! - operationId: authenticate login + description: renew token! + operationId: renew-token parameters: - - description: auth info + - description: refresh token in: body - name: Credentials + name: refreshToken required: true schema: - $ref: '#/definitions/auth.Credentials' + type: string produces: - application/json responses: "200": - description: STATUS OK + description: OK + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "400": + description: BAD REQUEST + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "401": + description: UNAUTHORIZED + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + security: + - ApiKeyAuth: [] + tags: + - Account + /api/account/send-code: + post: + consumes: + - application/json + description: send reset password code! + operationId: reset-password-code + parameters: + - description: reset password email info + in: body + name: EmailData + required: true + schema: + $ref: '#/definitions/dto.EmailData' + produces: + - application/json + responses: + "204": + description: NO CONTENT schema: allOf: - $ref: '#/definitions/http.Response' @@ -191,8 +408,44 @@ paths: content: type: string type: object - "403": - description: STATUS FORBIDDEN + "500": + description: INTERNAL SERVER ERROR + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + tags: + - Account + /api/account/update: + patch: + consumes: + - application/json + description: Update account username and/or email + operationId: update-account + parameters: + - description: update account info + in: body + name: UpdateAccount + required: true + schema: + $ref: '#/definitions/dto.UpdateAccount' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "401": + description: UNAUTHORIZED schema: allOf: - $ref: '#/definitions/http.Response' @@ -209,26 +462,28 @@ paths: content: type: string type: object + security: + - ApiKeyAuth: [] tags: - - Auth - /api/auth/authorize: + - Account + /api/account/validate-code: post: consumes: - application/json - description: verify if request is valid! - operationId: authenticate request + description: validate reset password code! + operationId: validate-password-code parameters: - - description: authorization data + - description: reset password data info in: body - name: AuthorizationData + name: ResetCodeData required: true schema: - $ref: '#/definitions/auth.AuthorizationData' + $ref: '#/definitions/dto.ResetCodeData' produces: - application/json responses: - "200": - description: STATUS OK + "204": + description: NO CONTENT schema: allOf: - $ref: '#/definitions/http.Response' @@ -245,6 +500,15 @@ paths: content: type: string type: object + "401": + description: UNAUTHORIZED + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object "500": description: INTERNAL SERVER ERROR schema: @@ -255,13 +519,109 @@ paths: type: string type: object tags: - - Auth - /api/auth/config: + - Account + /api/account/validate/{accountID}: get: consumes: - application/json - description: get actual type! - operationId: get type + description: validate email! + operationId: validate-email + parameters: + - description: accountID of the account + in: path + name: accountID + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "400": + description: BAD REQUEST + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "500": + description: INTERNAL SERVER ERROR + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + tags: + - Account + /api/account/verify-already-used: + post: + consumes: + - application/json + description: Verify if email and username already in use! + operationId: validate-unique + parameters: + - description: validate unique info + in: body + name: ValidateUnique + required: true + schema: + $ref: '#/definitions/dto.ValidateUnique' + produces: + - application/json + responses: + "201": + description: STATUS CREATED + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "400": + description: BAD REQUEST + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + "500": + description: INTERNAL SERVER ERROR + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + tags: + - Account + /api/auth/authenticate: + post: + consumes: + - application/json + description: authenticate login by type! + operationId: authenticate login + parameters: + - description: auth info + in: body + name: Credentials + required: true + schema: + $ref: '#/definitions/dto.Credentials' produces: - application/json responses: @@ -272,7 +632,7 @@ paths: - $ref: '#/definitions/http.Response' - properties: content: - $ref: '#/definitions/auth.ConfigAuth' + type: string type: object "400": description: BAD REQUEST @@ -283,6 +643,35 @@ paths: content: type: string type: object + "500": + description: INTERNAL SERVER ERROR + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object + tags: + - Auth + /api/auth/config: + get: + consumes: + - application/json + description: get actual type! + operationId: get type + produces: + - application/json + responses: + "200": + description: STATUS OK + schema: + allOf: + - $ref: '#/definitions/http.Response' + - properties: + content: + type: string + type: object tags: - Auth /api/health: diff --git a/horusec-auth/internal/controller/account/account.go b/horusec-auth/internal/controller/account/account.go index fc426ffe8..f39ad2504 100644 --- a/horusec-auth/internal/controller/account/account.go +++ b/horusec-auth/internal/controller/account/account.go @@ -226,12 +226,17 @@ func (a *Account) ChangePassword(accountID uuid.UUID, password string) error { logger.LogError("{ACCOUNT} Error on validate password: ", err) return errors.ErrorInvalidPassword } - account.Password = password - account.SetPasswordHash() + account = a.setNewPasswordInAccount(account, password) _ = a.cacheRepository.Del(accountID.String()) return a.accountRepository.Update(account) } +func (a *Account) setNewPasswordInAccount(account *authEntities.Account, password string) *authEntities.Account { + account.Password = password + account.SetPasswordHash() + return account +} + func (a *Account) RenewToken(refreshToken, accessToken string) (*dto.LoginResponse, error) { accountID, _ := jwt.GetAccountIDByJWTToken(accessToken) account, err := a.accountRepository.GetByAccountID(accountID) diff --git a/horusec-auth/internal/handler/account/account.go b/horusec-auth/internal/handler/account/account.go index 5618327d1..a23528d03 100644 --- a/horusec-auth/internal/handler/account/account.go +++ b/horusec-auth/internal/handler/account/account.go @@ -57,8 +57,8 @@ func (h *Handler) Options(w http.ResponseWriter, _ *http.Request) { // @ID create-account-keycloak // @Accept json // @Produce json -// @Param KeycloakToken body account.KeycloakToken true "keycloak token info" -// @Success 200 {object} http.Response{content=account.CreateAccountFromKeycloakResponse{}} "STATUS OK" +// @Param KeycloakToken body dto.KeycloakToken true "keycloak token info" +// @Success 200 {object} http.Response{content=dto.CreateAccountFromKeycloakResponse} "STATUS OK" // @Success 201 {object} http.Response{content=string} "STATUS CREATED" // @Failure 400 {object} http.Response{content=string} "BAD REQUEST" // @Failure 500 {object} http.Response{content=string} "INTERNAL SERVER ERROR" @@ -94,7 +94,7 @@ func (h *Handler) checkCreateAccountFromKeycloakErrors( // @ID create-account // @Accept json // @Produce json -// @Param CreateAccount body account.CreateAccount true "create account info" +// @Param CreateAccount body dto.CreateAccount true "create account info" // @Success 201 {object} http.Response{content=string} "STATUS CREATED" // @Failure 400 {object} http.Response{content=string} "BAD REQUEST" // @Failure 500 {object} http.Response{content=string} "INTERNAL SERVER ERROR" @@ -154,7 +154,7 @@ func (h *Handler) ValidateEmail(w http.ResponseWriter, r *http.Request) { // @ID reset-password-code // @Accept json // @Produce json -// @Param EmailData body account.EmailData true "reset password email info" +// @Param EmailData body dto.EmailData true "reset password email info" // @Success 204 {object} http.Response{content=string} "NO CONTENT" // @Failure 400 {object} http.Response{content=string} "BAD REQUEST" // @Failure 500 {object} http.Response{content=string} "INTERNAL SERVER ERROR" @@ -189,7 +189,7 @@ func (h *Handler) checkSendResetPasswordCodeErrors(w http.ResponseWriter, err er // @ID validate-password-code // @Accept json // @Produce json -// @Param ResetCodeData body account.ResetCodeData true "reset password data info" +// @Param ResetCodeData body dto.ResetCodeData true "reset password data info" // @Success 204 {object} http.Response{content=string} "NO CONTENT" // @Failure 400 {object} http.Response{content=string} "BAD REQUEST" // @Failure 401 {object} http.Response{content=string} "UNAUTHORIZED" @@ -335,7 +335,7 @@ func (h *Handler) Logout(w http.ResponseWriter, r *http.Request) { // @ID validate-unique // @Accept json // @Produce json -// @Param ValidateUnique body account.ValidateUnique true "validate unique info" +// @Param ValidateUnique body dto.ValidateUnique true "validate unique info" // @Success 201 {object} http.Response{content=string} "STATUS CREATED" // @Failure 400 {object} http.Response{content=string} "BAD REQUEST" // @Failure 500 {object} http.Response{content=string} "INTERNAL SERVER ERROR" @@ -386,10 +386,11 @@ func (h *Handler) DeleteAccount(w http.ResponseWriter, r *http.Request) { // @ID update-account // @Accept json // @Produce json +// @Param UpdateAccount body dto.UpdateAccount true "update account info" // @Success 200 {object} http.Response{content=string} "OK" // @Failure 401 {object} http.Response{content=string} "UNAUTHORIZED" // @Failure 500 {object} http.Response{content=string} "INTERNAL SERVER ERROR" -// @Router /api/account/delete [delete] +// @Router /api/account/update [patch] // @Security ApiKeyAuth func (h *Handler) Update(w http.ResponseWriter, r *http.Request) { data, err := h.getAccountUpdateData(w, r) diff --git a/horusec-auth/internal/handler/auth/auth.go b/horusec-auth/internal/handler/auth/auth.go index a2cf47385..6937ccdf2 100644 --- a/horusec-auth/internal/handler/auth/auth.go +++ b/horusec-auth/internal/handler/auth/auth.go @@ -15,7 +15,7 @@ package auth import ( - "github.com/ZupIT/horusec/development-kit/pkg/entities/auth/dto" + authDTO "github.com/ZupIT/horusec/development-kit/pkg/entities/auth/dto" authEnums "github.com/ZupIT/horusec/development-kit/pkg/enums/auth" "github.com/ZupIT/horusec/development-kit/pkg/enums/errors" netHTTP "net/http" @@ -54,7 +54,7 @@ func (h *Handler) Options(w netHTTP.ResponseWriter, _ *netHTTP.Request) { // @ID get type // @Accept json // @Produce json -// @Success 200 {object} http.Response{content=auth.ConfigAuth}} "STATUS OK" +// @Success 200 {object} http.Response{content=string} "STATUS OK" // @Router /api/auth/config [get] func (h *Handler) Config(w netHTTP.ResponseWriter, _ *netHTTP.Request) { httpUtil.StatusOK(w, auth.ConfigAuth{ @@ -68,7 +68,7 @@ func (h *Handler) Config(w netHTTP.ResponseWriter, _ *netHTTP.Request) { // @ID authenticate login // @Accept json // @Produce json -// @Param Credentials body auth.Credentials true "auth info" +// @Param Credentials body dto.Credentials true "auth info" // @Success 200 {object} http.Response{content=string} "STATUS OK" // @Failure 400 {object} http.Response{content=string} "BAD REQUEST" // @Failure 500 {object} http.Response{content=string} "INTERNAL SERVER ERROR" @@ -89,7 +89,7 @@ func (h *Handler) AuthByType(w netHTTP.ResponseWriter, r *netHTTP.Request) { httpUtil.StatusOK(w, response) } -func (h *Handler) getCredentials(r *netHTTP.Request) (*dto.Credentials, error) { +func (h *Handler) getCredentials(r *netHTTP.Request) (*authDTO.Credentials, error) { credentials, err := h.authUseCases.NewCredentialsFromReadCloser(r.Body) if err != nil { return credentials, err