Skip to content

Commit

Permalink
πŸ” implementing authentication with OTP (#109)
Browse files Browse the repository at this point in the history
* feat: πŸ” implementing authentication with OTP

* fix: fixing error function name

* test: βœ… add benchmark testing on package otp

* feat: πŸ“„ add license on file top

* feat: add function to get qr code url

* feat: ✨ route to fetch qr code url to configure a user's otp

* docs: πŸ“ update documentation swag

* feat: πŸ” adding validation to access a user's data

* fix: test

* feat: ✨ add function to configure otp

* fix: fix test

* fix: fix test 2

* feat: add command to run test in makefile

* feat: update lib gopowersso

* fix: remove translate not used

* feat: using middleware SameUser in otp Router's

* refact: remove validation same user (otp)

* test: improving test of otp

* refact: refactoring variables on business of otp

* feat: add router of unconfigure otp

* test: add test of the router of unconfigure the otp

* feat: add router of login steps

* test: add test of router the login steps

* feat: update docs

* fix: remove comment TODO
  • Loading branch information
isaqueveras committed Mar 8, 2023
1 parent 9fb2af8 commit 4c1b351
Show file tree
Hide file tree
Showing 36 changed files with 1,329 additions and 78 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ DB_LOCAL := "postgres://postgres:postgres@localhost:5432/power-sso?sslmode=disab
run:
go run main.go

test:
go test ./...

local:
docker compose -f docker-compose.local.yml up -d --build

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<p style="max-width: 70%"><i>PowerSSO is a fundamental piece that authenticates and manages users with the possibility of integration between systems using a Rest API and gRPC</i></p>

<p>
<img alt="Go report" src="https://goreportcard.com/badge/isaqueveras/power-sso">
<img alt="" src="https://github.com/isaqueveras/power-sso/actions/workflows/go.yml/badge.svg">
<img alt="Repository size" src="https://img.shields.io/github/languages/top/isaqueveras/power-sso">
<img alt="GitHub language count" src="https://img.shields.io/github/languages/count/isaqueveras/power-sso?color=%2304D361">
<img alt="GitHub top language" src="https://img.shields.io/github/repo-size/isaqueveras/power-sso">
Expand Down
168 changes: 161 additions & 7 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2023-02-11 16:58:20.668754441 -0300 -03 m=+0.019358123
// 2023-03-08 20:50:40.624770349 -0300 -03 m=+0.303424087

package docs

Expand Down Expand Up @@ -79,6 +79,30 @@ var doc = `{
}
}
},
"/v1/auth/login/steps": {
"get": {
"description": "Steps to login",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Http/Auth"
],
"summary": "Steps to login",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"$ref": "#/definitions/auth.StepsResponse"
}
}
}
}
},
"/v1/auth/logout": {
"delete": {
"description": "Route to logout a user account into the system",
Expand Down Expand Up @@ -127,6 +151,111 @@ var doc = `{
}
}
},
"/v1/auth/user/{user_uuid}/disable": {
"put": {
"description": "Route to disable a user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Http/Auth/User"
],
"summary": "Disable user",
"parameters": [
{
"type": "string",
"description": "UUID of the user",
"name": "user_uuid",
"in": "path",
"required": true
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"type": "object",
"$ref": "#/definitions/utils.NoContent"
}
}
}
}
},
"/v1/auth/user/{user_uuid}/otp/configure": {
"post": {
"description": "Configure a user's OTP",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Http/Auth/OTP"
],
"summary": "Configure a user's OTP",
"responses": {
"201": {
"description": "Created",
"schema": {
"type": "object",
"$ref": "#/definitions/utils.NoContent"
}
}
}
}
},
"/v1/auth/user/{user_uuid}/otp/qrcode": {
"get": {
"description": "Configure a user's OTP",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Http/Auth/OTP"
],
"summary": "Configure a user's OTP",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"$ref": "#/definitions/otp.QRCodeResponse"
}
}
}
}
},
"/v1/auth/user/{user_uuid}/otp/unconfigure": {
"put": {
"description": "unconfigure a user's OTP",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Http/Auth/OTP"
],
"summary": "unconfigure a user's OTP",
"responses": {
"201": {
"description": "Created",
"schema": {
"type": "object",
"$ref": "#/definitions/utils.NoContent"
}
}
}
}
},
"/v1/project/create": {
"post": {
"description": "Register a project including several users to the project",
Expand Down Expand Up @@ -165,6 +294,9 @@ var doc = `{
"created_at": {
"type": "string"
},
"data": {
"type": "object"
},
"email": {
"type": "string"
},
Expand All @@ -174,21 +306,21 @@ var doc = `{
"first_name": {
"type": "string"
},
"jwt_token": {
"type": "string"
},
"last_name": {
"type": "string"
},
"level": {
"type": "string"
},
"otp_enabled": {
"type": "boolean"
},
"otp_setup": {
"type": "boolean"
},
"phone_number": {
"type": "string"
},
"raw_data": {
"type": "object"
},
"roles": {
"type": "array",
"items": {
Expand All @@ -198,11 +330,33 @@ var doc = `{
"session_id": {
"type": "string"
},
"token": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"auth.StepsResponse": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"otp": {
"type": "boolean"
}
}
},
"otp.QRCodeResponse": {
"type": "object",
"properties": {
"url": {
"type": "string"
}
}
},
"utils.NoContent": {
"type": "object"
}
Expand Down
Loading

1 comment on commit 4c1b351

@vercel
Copy link

@vercel vercel bot commented on 4c1b351 Mar 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

power-sso – ./

power-sso-git-main-isaqueveras.vercel.app
power-sso.vercel.app
power-sso-isaqueveras.vercel.app

Please sign in to comment.