-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
9,452 additions
and
1 deletion.
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 +1,2 @@ | ||
/.idea/dictionaries/enbock.xml | ||
node_modules |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,2 @@ | ||
bode_modules | ||
build |
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,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="jdk" jdkName="15" jdkType="JavaSDK" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
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,130 @@ | ||
# MFA-Backend | ||
|
||
Ein einfaches MFA-Backend, das TOTP-Tokens generiert und validiert. Dieses Projekt verwendet TypeScript und läuft auf | ||
AWS Lambda. Es verwendet die Serverless Framework für einfaches Deployment. | ||
|
||
## Voraussetzungen | ||
|
||
- Node.js (empfohlen: v20.x) | ||
- npm (Node Package Manager) | ||
- Serverless Framework (`npm install -g serverless`) | ||
|
||
## Installation | ||
|
||
1. Abhängigkeiten installieren: | ||
|
||
```bash | ||
npm install | ||
``` | ||
|
||
1. TypeScript Compiler-Konfiguration anpassen (optional): | ||
|
||
```bash | ||
npx tsc --init | ||
``` | ||
|
||
## Konfiguration | ||
|
||
Serverless Framework ist bereits konfiguriert, um die Lambda-Funktionen zu deployen. Die `serverless.yml` Datei enthält | ||
die Konfiguration. | ||
|
||
## Projektstruktur | ||
|
||
- `Application`: Enthält die Delivery-Schicht, z.B. Handlers, Presenter und den Dependency Injection Container. | ||
- `Core`: Enthält die Geschäftslogik, z.B. den `MFAService` und Interfaces für Abhängigkeiten. | ||
- `Infrastructure`: Enthält Low-Level Implementierungen wie den `CryptoService` und den `InMemoryTokenStore`. | ||
|
||
## Lokales Testen | ||
|
||
Du kannst die Lambda-Funktionen lokal mit dem Serverless Framework testen: | ||
|
||
```bash | ||
serverless offline | ||
``` | ||
|
||
## Deployment | ||
|
||
Um das Service zu AWS zu deployen, benutze: | ||
|
||
```bash | ||
serverless deploy | ||
``` | ||
|
||
Nach dem Deployment erhältst du eine URL, über die deine API-Endpunkte erreichbar sind. | ||
|
||
## Endpunkte und Verwendung | ||
|
||
1. **Token generieren** | ||
|
||
- **URL**: `POST /generate-token` | ||
- **Body**: | ||
|
||
```json | ||
{ | ||
"userId": "user123" | ||
} | ||
``` | ||
|
||
- **Antwort**: | ||
- **200 OK**: | ||
|
||
```json | ||
{ | ||
"message": "Token generated", | ||
"token": "123456", | ||
"otpauth": "otpauth://totp/YourAppName:user123?secret=SECRET_KEY&issuer=YourAppName" | ||
} | ||
``` | ||
|
||
- **400 Bad Request**: | ||
|
||
```json | ||
{ | ||
"message": "User ID is required" | ||
} | ||
``` | ||
|
||
2. **Token validieren** | ||
|
||
- **URL**: `POST /validate-token` | ||
- **Body**: | ||
|
||
```json | ||
{ | ||
"userId": "user123", | ||
"token": "123456" | ||
} | ||
``` | ||
|
||
- **Antwort**: | ||
- **200 OK**: | ||
|
||
```json | ||
{ | ||
"message": "Token is valid" | ||
} | ||
``` | ||
|
||
- **401 Unauthorized**: | ||
|
||
```json | ||
{ | ||
"message": "Invalid token" | ||
} | ||
``` | ||
|
||
- **400 Bad Request**: | ||
|
||
```json | ||
{ | ||
"message": "User ID and token are required" | ||
} | ||
``` | ||
|
||
## Beitrag leisten | ||
|
||
Beiträge sind willkommen! Bitte erstelle einen Pull-Request und beschreibe Änderungen. | ||
|
||
## Lizenz | ||
|
||
Dieses Projekt ist lizenziert unter der MIT-Lizenz. |
Oops, something went wrong.