-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
for two factor authentication Signed-off-by: William <[email protected]>
- Loading branch information
Showing
14 changed files
with
293 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
PG_HOST=localhost | ||
PG_USER= | ||
PG_PASSWORD= | ||
PG_DB=apiauth | ||
PG_PORT= | ||
PG_USER=postgres | ||
PG_PASSWORD=postgres | ||
PG_DB=auth_server | ||
PG_PORT=5432 | ||
PG_CERT= | ||
PG_SSL=True | ||
JWT_SECRET= | ||
SMTP_HOST= | ||
SMTP_PORT=25 | ||
PG_SSL=False | ||
JWT_SECRET=Jwttestt1111 | ||
SMTP_HOST=mailhog | ||
SMTP_PORT=1025 | ||
SMTP_USERNAME= | ||
SMTP_PASSWORD= | ||
FROM_EMAIL_ADDRESS= | ||
FROM_EMAIL_ADDRESS=test@localhost | ||
SERVER_ADDRESS= | ||
SERVER_PORT=8080 | ||
TOKEN_EXPIRY_TIME=15m | ||
ISSUER_NAME= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
BEGIN; | ||
ALTER TABLE users DROP COLUMN two_factor_type; | ||
ALTER TABLE users DROP COLUMN totp_secret; | ||
ALTER TABLE users DROP COLUMN totp_created; | ||
ALTER TABLE users DROP COLUMN totp_url; | ||
ALTER TABLE two_factor_requests DROP COLUMN send_type; | ||
DROP TYPE two_factor_type; | ||
DROP TYPE send_type; | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
BEGIN; | ||
-- CREATE TYPES | ||
CREATE TYPE enum_two_factor_type AS ENUM ('SMS','EMAIL','TOTP','NONE'); | ||
CREATE TYPE enum_send_type AS ENUM ('SMS','EMAIL'); | ||
-- CREATE new columns | ||
ALTER TABLE users ADD COLUMN two_factor_type enum_two_factor_type; | ||
-- Update to email | ||
UPDATE users SET two_factor_type = 'EMAIL' WHERE two_factor_enabled = True; | ||
UPDATE users SET two_factor_type = 'NONE' WHERE two_factor_enabled = False; | ||
-- Add hotop columns | ||
ALTER TABLE users ADD COLUMN totp_secret VARCHAR ; | ||
UPDATE users SET totp_secret = ''; | ||
ALTER TABLE users ADD COLUMN totp_url VARCHAR ; | ||
UPDATE users SET totp_url = ''; | ||
ALTER TABLE users ADD COLUMN totp_created TIMESTAMP ; | ||
-- Update previous records send type to email since there was no other option except email | ||
ALTER TABLE two_factor_requests ADD COLUMN send_type enum_send_type NOT NULL; | ||
UPDATE two_factor_requests SET send_type = 'EMAIL'; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package services | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/kwesidev/authserver/internal/utilities" | ||
_ "github.com/lib/pq" | ||
) | ||
|
||
func TestValidLogin(t *testing.T) { | ||
db, err := utilities.GetMainDatabaseConnection(utilities.DatabaseConfig{ | ||
Host: "localhost", | ||
Userame: "postgres", | ||
Password: "root", | ||
Database: "apiauth", | ||
Port: "5432", | ||
}) | ||
if err != nil { | ||
t.Error("Connection to database failed: ", err) | ||
return | ||
} | ||
authService := NewAuthService(db) | ||
_, err = authService.Login("jackie", "password", "", "") | ||
|
||
if err != nil { | ||
t.Error("Failed to authenticate") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.