diff --git a/README.md b/README.md index 620cff8d1..7559c30ac 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,10 @@ Currently we only support `docker` as environment to run all services, since man - [docker](https://www.docker.com/) ## How to run? - -`docker-compose up` +```bash +git submodule update --recursive --init +docker-compose up +``` ## Useful Links diff --git a/community_server b/community_server index 3bbd8d0b7..7ebc7909e 160000 --- a/community_server +++ b/community_server @@ -1 +1 @@ -Subproject commit 3bbd8d0b7cc5ba2f03a1d7e8c95f0f9290ae265a +Subproject commit 7ebc7909eaf9e74ca81f561b0aac64797c3d0112 diff --git a/configs/login_server/grd_login.properties b/configs/login_server/grd_login.properties index 7719bc563..76b4b2d10 100644 --- a/configs/login_server/grd_login.properties +++ b/configs/login_server/grd_login.properties @@ -47,3 +47,4 @@ session.timeout = 15 # Disabling security features for faster develop and testing unsecure.allow_passwort_via_json_request = 1 unsecure.allow_auto_sign_transactions = 1 +unsecure.allow_cors_all = 1 diff --git a/docu/community-server.api.md b/docu/community-server.api.md new file mode 100644 index 000000000..0c889d7ae --- /dev/null +++ b/docu/community-server.api.md @@ -0,0 +1,96 @@ +# community server api + +In this examples I assume that you use gradido with or docker-compose build on your local maschine + +## Konto Overview +return current account balance + +GET http://localhost/state-balances/ajaxGetBalance/-127182 + +If session is valid, return: +```json +{"state":"success","balance":174500} +``` +- balance: Gradido Cent, 4 Nachkommastellen (2 Reserve), 174500 = 17,45 GDD + +## List Transactions +List all transactions from logged in user, currently without paging +Ajax: +GET http://localhost/state-balances/ajaxListTransactions/-127182 + +Antwort: +Wenn alles okay: +```json +{"state":"success", "transactions": + [ + { + "name": "Max Mustermann", + "email": "Maxim Mustermann", + "type": "send", + "transaction_id": 2, + "date": "2021-02-19T13:25:36+00:00", + "balance": 1920000, + "memo": "a piece of cake :)", + "pubkey": "038a6f93270dc57b91d76bf110ad3863fcb7d1b08e7692e793fcdb4467e5b6a7" + } + ], + "transactionExecutingCount": 0, + "count": 1, + "gdtSum": 0, + "timeUsed": 0.04562687873840332 +} +``` + +- name: name of other involved party or empty if unknown (if other party don't belong to group) + - if type is send, name is name of receiver + - if type is receive, name is name of sender + - if type is creation currently I use a static string ("Gradido Akademie) +- email: optional, only if type is send or receive and other user is known +- pubkey: optional, only if type is send or receive and other user isn't known +- type: type of transaction + - creation: user has get gradidos created + - send: user has send another user gradidos + - receiver: user has received gradidos from another user +- transaction_id: id of transaction in db, in stage2 also the hedera sequence number of transaction +- date: date of ordering transaction (booking date) +- balance: Gradido Cent, 4 Nachkommastellen (2 Reserve), 1920000 = 192,00 GDD +- memo: Details about transaction +- pubkey: optional, if other party isn't known, hexadecimal representation of 32 Byte public key of user [0-9a-f] + +- transactionExecutingCount: how many transaction for this user currently pending and waiting for signing +- count: sum of finished transactions user is involved +- gdtSum: sum of gdt of user in cent with 2 places (Nachkommastellen) +- timeUsed: time used for getting data from db in seconds, only for analyse backend performance + +## Send Coins Transaction +Make a simple GDD Transaction, send Coins from one user to other. +With new Option set in Login-Server: +```ini +unsecure.allow_auto_sign_transactions = 1 +``` +transactions can be auto-signed directly with handing in transaction. +Normally a forwarding to login-server check transactions side is neccessary to minimize security risks. + +POST http://localhost/transaction-send-coins/ajaxCreate +```json +{"session_id" : -127182, "amount": 2000000, "email": "maxim.mustermann@gmail.com", "memo":"Thank you :)", "auto_sign": true} +``` +- amout: amount to transfer, 2000000 = 200,00 GDD +- email: receiver email address, must be differ from user email +- memo: Details about transaction +- auto_sign: set to true to directly sign transaction if unsecure.allow_auto_sign_transactions = 1 is set + +return if everything is ok: +```json +{"state":"success", "timeUsed": 0.0122} +``` +- timeUsed: time used for getting data from db in seconds, only for analyse backend performance + +Than the transaction was created on community server, send to login-server, signed (if unsecure.allow_auto_sign_transactions = 1 and auto_sign = true) +and send back to community server and put into db. +After you get this answear you see the new transaction if you list transactions or call for the balance. + +Without auto-sign the transaction is pending on login-server and waits for the user to review it at +http://localhost/account/checkTransactions + + diff --git a/docu/frontend_vue.drawio b/docu/frontend_vue.drawio new file mode 100644 index 000000000..98002cf5c --- /dev/null +++ b/docu/frontend_vue.drawio @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docu/frontend_vue.png b/docu/frontend_vue.png new file mode 100644 index 000000000..9647f51b0 Binary files /dev/null and b/docu/frontend_vue.png differ diff --git a/docu/login_server.api.md b/docu/login_server.api.md new file mode 100644 index 000000000..c4eb123eb --- /dev/null +++ b/docu/login_server.api.md @@ -0,0 +1,103 @@ +# login server api + +Gradido js-Frontend vereinfachte Zusammenarbeit mit Login-Server und Community-Server + +Es ist mit einer Zusatz-Option möglich das Login und Registrieren via ajax-Request passiern kann. +Dafür muss in der Login-Server Config + +```ini +unsecure.allow_passwort_via_json_request = 1 +``` + +gesetzt sein. + +mit: +```ini +unsercure.allow_cors_all = 1 +``` +Wird bei allen JSON-Requests zum Header: Access-Control-Allow-Origin:* +hinzugefügt. + +In diesen Beispielen gehe ich jetzt davon aus, das du das gesamte Gradido Projekt mit Docker gebaut hast und auf dem lokalen Rechner laufen lässt. + +Login +Einloggen über: + + +## unsecureLogin + +POST http://localhost/login_api/unsecureLogin +```json +data: {"email": "max.musterman@gmail.de", "password": "123abcDE&"} +``` + +Wenn alles okay ist erhältst du zum Beispiel: +```json +{"state":"success", "session_id": -127182, "clientIP":"52.68.96.58", + "user": { + "created": 1293872400, + "disabled": false, + "email": "max.musterman@gmail.de", + "email_checked": true, + "first_name": "Max", + "group_alias": "gdd1", + "ident_hash": 1829912, + "public_hex": "c6e7d6a697fa74d6c247580edf1546989d43487575e21e398abe3cc2094bd63e", + "last_name": "Musterman", + "role": "none", + "username": "", + "balance": 174500, + "id": 1, + "errorCount": 0 +}} +``` +- clientIP: should be the same as where the js-client is running, else maybe a man-in-the-middle attacks is happening or +nginx was wrong configured. +- session_id: can be also negative +- created: unix timestamp in seconds +- disabled: if set to true, login and every transaction must fail. Currently used if use would like to have there account deleted. +- email_checked: true if user has already clicked on email verification code link in his emails, needed for tranactions +- ident_hash: string hash from email, used for speed up creation validation +- public_hex: hexadecimal representation of 32 Byte public key of user [0-9a-f] +- role: not intended for future use, just ignore, login-server admin will be independently from community-server admin +- username: for later use +- balance: Gradido Cent, 4 Nachkommastellen (2 Reserve), 174500 = 17,45 GDD +- id: login-server user id, only needed for debugging +- errorCount: errors occured in this session, should be normally 0 + +Anmelden +Registrieren kannst du einen neuen Benutzer mit: + + +## createUser + +POST http://localhost/login_api/createUser +```json +data: {"email":"max.musterman@gmail.de", "first_name":"Max", "last_name":"Musterman" , + "emailType": 2, "password":"123abcDE&"} +``` + +- emailType: control email-text sended with email verification code + - 2: default, if user has registered directly + - 5: if user was registered by an admin + +Wenn alles okay ist erhältst du: +```json +{"state":"success"} +``` + +Dann wurde für den Benutzer ein neues Konto angelegt, seine Schlüssel generiert und ihm eine Bestätigungs-Email geschickt. + + +## Logout + +Abmelden +POST http://localhost/login_api/logout +```json +data: {"session_id": -127182} +``` + +Wenn alles okay ist erhältst du: +```json +{"state":"success"} +``` \ No newline at end of file diff --git a/login_server b/login_server index a89e0c8e1..9b9115290 160000 --- a/login_server +++ b/login_server @@ -1 +1 @@ -Subproject commit a89e0c8e1360edfac81b3e73923690f7f1da7b5e +Subproject commit 9b9115290c8d2ead756d64b70ae63a6571aa4693 diff --git a/logs/.gitignore b/logs/.gitignore new file mode 100644 index 000000000..c96a04f00 --- /dev/null +++ b/logs/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file