From b631556d30c48fbed704fbcaa59c5a6fae36bc41 Mon Sep 17 00:00:00 2001 From: AaronR92 <86726028+AaronR92@users.noreply.github.com> Date: Sun, 3 Jul 2022 17:16:25 +0300 Subject: [PATCH] Create README.md --- README.md | 226 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..8e164ef --- /dev/null +++ b/README.md @@ -0,0 +1,226 @@ + +# Account Service + +REST service for company to handle employees' salaries and authorities. + +### Info +All regitred emails must end with @acme.com, this can be changed in +User entity at field email +Service also has breached passwords table in the database. +## Tech Stack + +**Spring Boot** + +**Spring Security** + +**Spring Data JPA** + +**Project lombok** + +**MySQL database** + +## Requests and authorization + +Security requirements based on the **ASVS** + +| | Anonymous | User | Accountant | Administrator | Auditor | +| :-------------------------- | :-------- | :--- | :--------- | :------------ | :------ | +| `POST api/auth/signup` | + | + | + | + | - | +| `POST api/auth/changepass` | - | + | + | + | - | +| `GET api/empl/payment` | - | + | + | - | - | +| `POST api/acct/payments` | - | - | + | - | - | +| `PUT api/acct/payments` | - | - | + | - | - | +| `GET api/admin/user` | - | - | - | + | - | +| `DELETE api/admin/user` | - | - | - | + | - | +| `PUT api/admin/user/role` | - | - | - | + | - | +| `PUT api/admin/user/access` | - | - | - | + | - | +| `GET api/security/events` | - | - | - | - | + | + + + +## API + +### Sign up + +``` + POST api/auth/signup +``` +#### Request body +```json +{ + "name": "", + "lastname": "", + "email": "", + "password": "" +} +``` + +#### Description +Saves new employee in the database, password must be longer than 12 chars. +First registred user gets administrator authorities. + + +### Change password + +``` + POST api/auth/changepass +``` +#### Request body +```json +{ + "email": "", + "new_password": "" +} +``` +#### Description +Saves new employees password in the database, password must be longer than 12 chars. + + +### Get payrolls + +``` + GET api/empl/payment +``` +#### Request parameters +| Parameter | Type | Description | +| :-------- | :------- | :------------------------------------------- | +| `period` | `string` | **Not required**. Period of payment to fetch | + +#### Description +Returns all payments of user that send the request, if a period is specified returns his payroll. + + +### Add new payrolls + +``` + POST api/acct/payments +``` +#### Request body +```json +[ + { + "employee": "", + "period": "", + "salary": + }, + { + "employee": "", + "period": "", + "salary": + }, + ... + { + "employee": "", + "period": "", + "salary": + } +] +``` + +#### Description +Adds new payrolls into database, must not be non-repetitive. + + +### Update payroll + +``` + PUT api/acct/payments +``` +#### Request body +```json +{ + "employee": "", + "period": "", + "salary": +} +``` + +#### Description +Updates the payroll with specified period. + + +### Get all users and thier roles + +``` + GET api/admin/user +``` + +#### Description +Returns a list of all registred users and thier authorities. + +### Delete user + +``` + DELETE api/admin/user/{email} +``` + +#### Request parameters +| Parameter | Type | Description | +| :-------- | :------- | :---------------------------------- | +| `period` | `@path` | **Required**. Users email to delete | + +#### Description +Deletes from database user with specified email. + + +### Update user authorities + +``` + PUT api/admin/user/role +``` +#### Request body +```json +{ + "user": "", + "role": "", + "operation": "<[GRANT, REMOVE]>" +} +``` + +#### Description +Updates user roles + + +### Lock/unlock user + +``` + PUT api/admin/user/access +``` +#### Request body +```json +{ + "user": "", + "operation": "<[LOCK, UNLOCK]>" +} +``` + +#### Description +Locks or unlocks specified user account + + +### Get all logs + +``` + GET api/security/events +``` + +#### Description +Returns a list of all logs. + +## Requirements +* Java 11 or higher +## Run + +#### 1. Download .jar file from releases + +#### 2. Open cmd and navigate to downloaded .jar file + +``` +cd +``` + +#### 3. Run jar + +``` +java -jar account-service.jar +``` \ No newline at end of file