diff --git a/services/backend/SequenceDiagram_AddReportReason.svg b/services/backend/SequenceDiagram_AddReportReason.svg new file mode 100644 index 0000000..91296f9 --- /dev/null +++ b/services/backend/SequenceDiagram_AddReportReason.svg @@ -0,0 +1,274 @@ + + +!requestFormatIsValid (Middleware)!user.isAdminreportingidentitySettingsaddReportReason(req:Request)res.status(200).end()res.status(200).end()insertReportReason(reportReason:Json)response.status(400).end()response.status(400).end()insertReportReason(reportReason:Json):AxiosRequestresponse.status(200).json(user.isAdmin)response.status(401).end()getUserFromTokenisUserAdmin(user_token:String):axiosRequest diff --git a/services/backend/SequenceDiagram_AddReportReason.uxf b/services/backend/SequenceDiagram_AddReportReason.uxf new file mode 100644 index 0000000..18e4fca --- /dev/null +++ b/services/backend/SequenceDiagram_AddReportReason.uxf @@ -0,0 +1,345 @@ + + + 10 + + UMLGeneric + + 310 + 70 + 100 + 30 + + _Settings_ + + + + UMLGeneric + + 670 + 70 + 100 + 30 + + _identity_ + + + + UMLGeneric + + 920 + 70 + 100 + 30 + + _reporting_ + + + + UMLSpecialState + + 120 + 160 + 20 + 20 + + type=initial + + + + UMLSpecialState + + 150 + 700 + 20 + 20 + + type=final + + + + Relation + + 350 + 90 + 30 + 90 + + lt=. + 10.0;10.0;10.0;70.0 + + + UMLGeneric + + 350 + 160 + 20 + 320 + + + + + + Relation + + 360 + 160 + 370 + 40 + + lt=<- +isUserAdmin(user_token:String):axiosRequest + 350.0;20.0;10.0;20.0 + + + Relation + + 710 + 90 + 30 + 100 + + lt=. + 10.0;10.0;10.0;80.0 + + + UMLGeneric + + 710 + 170 + 20 + 140 + + + + + + Relation + + 720 + 180 + 190 + 80 + + lt=<- +getUserFromToken + 10.0;60.0;50.0;60.0;50.0;10.0;10.0;10.0 + + + UMLFrame + + 140 + 300 + 310 + 100 + + !user.isAdmin + + + + Relation + + 160 + 330 + 210 + 40 + + lt=<. +response.status(401).end() + 10.0;20.0;190.0;20.0 + + + Relation + + 360 + 270 + 370 + 40 + + lt=<. +response.status(200).json(user.isAdmin) + 10.0;20.0;350.0;20.0 + + + UMLSpecialState + + 150 + 340 + 20 + 20 + + type=final + + + + UMLGeneric + + 960 + 420 + 20 + 270 + + + + + + Relation + + 960 + 90 + 30 + 350 + + lt=. + 10.0;10.0;10.0;330.0 + + + Relation + + 360 + 420 + 620 + 40 + + lt=<- +insertReportReason(reportReason:Json):AxiosRequest + 600.0;20.0;10.0;20.0 + + + UMLFrame + + 140 + 490 + 890 + 100 + + !requestFormatIsValid (Middleware) + + + + Relation + + 360 + 510 + 620 + 40 + + lt=<. +response.status(400).end() + 10.0;20.0;600.0;20.0 + + + Relation + + 350 + 470 + 30 + 70 + + lt=. + 10.0;10.0;10.0;50.0 + + + UMLGeneric + + 350 + 520 + 20 + 60 + + + + + + UMLSpecialState + + 150 + 550 + 20 + 20 + + type=final + + + + Relation + + 160 + 540 + 210 + 40 + + lt=<. +response.status(400).end() + 10.0;20.0;190.0;20.0 + + + Relation + + 970 + 590 + 340 + 90 + + lt=<- +insertReportReason(reportReason:Json) + 10.0;70.0;70.0;70.0;70.0;10.0;10.0;10.0 + + + Relation + + 350 + 570 + 30 + 120 + + lt=. + 10.0;10.0;10.0;100.0 + + + Relation + + 360 + 660 + 620 + 40 + + lt=<. +res.status(200).end() + 10.0;20.0;600.0;20.0 + + + UMLGeneric + + 350 + 670 + 20 + 60 + + + + + + Relation + + 160 + 690 + 210 + 40 + + lt=<. +res.status(200).end() + 10.0;20.0;190.0;20.0 + + + Relation + + 130 + 150 + 240 + 40 + + lt=<- +addReportReason(req:Request) + 220.0;20.0;10.0;20.0 + + diff --git a/services/backend/reporting.md b/services/backend/reporting.md index e69de29..8ac0c62 100644 --- a/services/backend/reporting.md +++ b/services/backend/reporting.md @@ -0,0 +1,61 @@ +#Reporting Service +- [Description](#description) +- [Rest interfaces](#Rest interfaces) + - [Reporting settings](#Reporting settings) + - [Security settings](#Security settings) +- [Example use case execution](#Example Add Report reason) + +##Description +The reporting service handles the reporting system. This includes administrative tasks like managing for which reasons +users can be reported, as well as the reporting system itself (reporting users and banning them). +The administrative tasks, like adding new report reasons, manually blocking and unblocking users, can be done via the +[settings service](settings.md). + +##Rest interfaces + +``` +GET: /report-reason/report-reason +``` +Returns all report reasons as a JSON array. + +``` +POST: /report-reason/report-reason +body: +{ + "reason": "some reason", + "max_report_violations": 5 +} +``` +adds a new report reason. + +``` +PUT: /report-reason/report-reason +body: +{ + "id": 123, + "reason": "some reason", + "max_report_violations": 5 +} +``` +Edits an existing report reason. + + +``` +DELETE: /report-reason/report-reason +headers: + - "id": 123 +``` +Deletes a report reason +``` +POST: /report +@param req request from the client. Follow this layout: + Headers: + - user_token +Body: + { + "username": "userHashOfUserBeingReported", + "reason_id": 123 + } +``` +used for reporting a user. Verifies if the user sending out the report has already reported the user for the same reason in the past 15 minutes. +In that case the report will not pass. Otherwise the report will be registered in the database \ No newline at end of file diff --git a/services/backend/settings.md b/services/backend/settings.md index e69de29..57cbdea 100644 --- a/services/backend/settings.md +++ b/services/backend/settings.md @@ -0,0 +1,90 @@ +#Settings Service +- [Description](#description) +- [Rest interfaces](#Rest interfaces) + - [Reporting settings](#Reporting settings) + - [Security settings](#Security settings) +- [Example use case execution](#Example Add Report reason) + +## Description +The Settings service provides an interface to the admin panel frontend and carries out the settings to the other services +As visible from the [Use Case diagram](#Use case diagram) the Settings service carries out a few tasks by itself whilst forwarding certain other request to the [identity service](identity-service.md) and the [reporting service](reporting.md). +The use cases and their descriptions can be found [here](../../usecases/index-admin.md). +##### Use Case Diagram +![UseCaseDiagram](../../usecases/UseCaseDiagramAdminPanel.png) + +###Rest interfaces + +The settings service provides the following rest endpoints: +####Reporting settings + +``` +GET: /settings/report-reason +``` +Returns all report reasons as a JSON array. + +``` +POST: /settings/report-reason +body: +{ + "reason": "some reason", + "max_report_violations": 5 +} +``` +adds a new report reason. + +``` +PUT: /settings/report-reason +body: +{ + "id": 123, + "reason": "some reason", + "max_report_violations": 5 +} +``` +Edits an existing report reason. + + +``` +DELETE: /settings/report-reason +headers: + - "id": 123 +``` +Deletes a report reason with an id that is provided as a header. + +####Security settings +``` +GET: /settings/security +``` +returns the current security settings. + +``` +PUT: /settings/security +body: +{ + "two_factor_auth": { + "on" : true, + "phone": false, + "email": true + }, + "confirmed_emails_only": true, + "individual_pwd_req": { + "on": true, + "upper_case": true, + "number": true, + "special_char": true, + "reg_ex": false, + "reg_ex_string": "[]" + }, + "inv_only": { + "on": false, + "inv_only_by_adm": false + } +} +``` +Edits the security settings. The new settings are provided in body. + +##Example Add Report reason +![Sequence Diagram](SequenceDiagram_AddReportReason.svg) +The sequence diagram shows an example of the communication of the settings service with the aforementioned services. +Firstly by checking at the identity service, if the user who sent out the request is in fact an administrator and then adding the reason in the reporting service. +This way each service has a clearly defined task.