From b3b3194a20da0fbdf9e4d5d37b62b3e77554e86b Mon Sep 17 00:00:00 2001 From: Jose Pablo Domingo Aramburo Sanchez Date: Wed, 15 Aug 2018 15:00:12 -0600 Subject: [PATCH 1/8] [add] Read me for the database --- database/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 database/README.md diff --git a/database/README.md b/database/README.md new file mode 100644 index 0000000..c76210c --- /dev/null +++ b/database/README.md @@ -0,0 +1,16 @@ +# The database + +#### The system has been built with the idea of running everything from within docker containers and due to that the following behaivor should be expected. + +#### A new docker image with mysql 5.7 will be created when docker-compose is called which will contain the starting scripts to create the database structure and anything else that is requiered to begin working as well as a config file to change the default port that is exposed. + +#### Once this process begins the database will be initialized by running the scripts in alphabetical order in the directory: +``` +/docker-entrypoint-initdb.d +``` + +#### After the database image has been created it'll be accessible by default in the port 3307, the users 'root' and 'sloth' will be usable both of which have the password 12345678 + +## Data persistence + +#### The database details will be stored in the volume mysql-data which is located in the volumes directory at the root of the project. From f3682019aac70f72f64abbf9cfb71c0dcb4e8fdb Mon Sep 17 00:00:00 2001 From: Jose Pablo Domingo Aramburo Sanchez Date: Wed, 15 Aug 2018 17:13:52 -0600 Subject: [PATCH 2/8] [add] Api documentation --- api-payroll/README.md | 50 ++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/api-payroll/README.md b/api-payroll/README.md index 189fa56..b9c5e38 100644 --- a/api-payroll/README.md +++ b/api-payroll/README.md @@ -1,27 +1,43 @@ -# Slim Framework 3 Skeleton Application +# The api -Use this skeleton application to quickly setup and start working on a new Slim Framework 3 application. This application uses the latest Slim 3 with the PHP-View template renderer. It also uses the Monolog logger. +### Database +##### The connection to the database is handled by pdo, it's configuraitions can be in the section mysql in the file +# +``` +src/settings.php +``` -This skeleton application was built for Composer. This makes setting up a new Slim Framework application quick and easy. +##### The default configurations for pdo are: +# +``` +PDO::ATTR_EMULATE_PREPARES +``` +###### By default true, to lower the strain on the database by processing the prepare statements on the server side, if cashe performance is desired this option should be changed to fale +# +``` +PDO::ATTR_ERRMODE +``` +###### Set to 'PDO::ERRMODE_EXCEPTION' which will return all mysql errors as exceptions to prevent further execution of the software +# -## Install the Application +``` +PDO::ATTR_DEFAULT_FETCH_MODE +``` +###### Set to 'PDO::FETCH_ASSOC' which will return the query output as an array of associative arrays where the alias or field name will be the key -Run this command from the directory in which you want to install your new Slim Framework application. +### Error handling +##### Should an exception be encountered it'll be caught by a middleware that will form a new response body, returning it with a 500 http code and a json object containing the keys status set to error as well as a message key that will contain the exeption that was raised and caused the error. - php composer.phar create-project slim/slim-skeleton [my-app-name] +### Sessions +When a user logs into the system a session will be created by apache, handle with its default behaivor by a cookie. -Replace `[my-app-name]` with the desired directory name for your new application. You'll want to: +### Data protection +Encryption has been applied to sensitive data, passwords are protected with with bcrypt and it's configuration can be found in the settings.php file, by default a cost of 12 is used for the hashing as well as a 16 characters randomly generated string (128 bits) as an iv. -* Point your virtual host document root to your new application's `public/` directory. -* Ensure `logs/` is web writeable. +For data that needs to be both read and written such as names AES in mode cbc with 256 block size has been used. -To run the application in development, you can run these commands +The reason to have choosen AES is the desire to make the process of securing the data both secure and affordable since many hardware manufacturers already have architectures designed to improce the speed of AES. - cd [my-app-name] - php composer.phar start +Important note: While in this project the encryption password has been saved into the settings.php file it's adviced that in a real use case it's stored more securely or else where entirely such as a key management service. -Run this command in the application directory to run the test suite - - php composer.phar test - -That's it! Now go build something cool. +### The endpoints From 2053742b11fa1d46f44e905c5c2247e91cd3ecc1 Mon Sep 17 00:00:00 2001 From: Jose Pablo Domingo Aramburo Sanchez Date: Wed, 15 Aug 2018 17:15:25 -0600 Subject: [PATCH 3/8] [add] Main readme --- README.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 430cec6..5c2e841 100644 --- a/README.md +++ b/README.md @@ -1 +1,57 @@ -# payroll_manager \ No newline at end of file +# Payroll manager + +#### This is a simple system to keep a record of employees where they will peform differnt tasks within the company and will be paid accordingly in a montly bases. + +## Getting started + +### Pre requisites +##### Installing docker +# +```sh +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + +sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + +sudo apt-get update + +apt-cache policy docker-ce + +sudo apt-get install -y docker-ce +``` + +##### Installing docker compose +# +```sh +sudo curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose + +sudo chmod +x /usr/local/bin/docker-compose +``` + +### Starting up +##### To initialize the system it can be run with docker compose which will create the service for apache + php and the mysql instance used by the service +# +```sh +sudo docker-compose up --build -d +``` + +##### Note: if the service is run without docker it'll be necesary to adjust the connection parameters in the file +# +``` +api-payroll/src/settings.php +``` +##### The login page can be accessed at +# +``` +http://localhost:8085/public/html/login.php +``` + +###### Note: To access the system the user is 'sloth' while the password is 'slothness' + +## For more detailed documentation about the different components: + [api-payroll](https://github.com/PootisPenserHere/payroll_manager/blob/master/api-payroll/README.md) + + [database](https://github.com/PootisPenserHere/payroll_manager/blob/master/database/README.md) + +### Data volumes + +### Considerations when calculating the salary From 78b319a0a32c16a295cdd713e4354bc00be979f6 Mon Sep 17 00:00:00 2001 From: Jose Pablo Domingo Aramburo Sanchez Date: Thu, 16 Aug 2018 03:43:45 -0600 Subject: [PATCH 4/8] [add] Format and extra data --- README.md | 57 ------------------------------------------- README.rst | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 57 deletions(-) delete mode 100644 README.md create mode 100644 README.rst diff --git a/README.md b/README.md deleted file mode 100644 index 5c2e841..0000000 --- a/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# Payroll manager - -#### This is a simple system to keep a record of employees where they will peform differnt tasks within the company and will be paid accordingly in a montly bases. - -## Getting started - -### Pre requisites -##### Installing docker -# -```sh -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - -sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - -sudo apt-get update - -apt-cache policy docker-ce - -sudo apt-get install -y docker-ce -``` - -##### Installing docker compose -# -```sh -sudo curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose - -sudo chmod +x /usr/local/bin/docker-compose -``` - -### Starting up -##### To initialize the system it can be run with docker compose which will create the service for apache + php and the mysql instance used by the service -# -```sh -sudo docker-compose up --build -d -``` - -##### Note: if the service is run without docker it'll be necesary to adjust the connection parameters in the file -# -``` -api-payroll/src/settings.php -``` -##### The login page can be accessed at -# -``` -http://localhost:8085/public/html/login.php -``` - -###### Note: To access the system the user is 'sloth' while the password is 'slothness' - -## For more detailed documentation about the different components: - [api-payroll](https://github.com/PootisPenserHere/payroll_manager/blob/master/api-payroll/README.md) - - [database](https://github.com/PootisPenserHere/payroll_manager/blob/master/database/README.md) - -### Data volumes - -### Considerations when calculating the salary diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..b1b5b94 --- /dev/null +++ b/README.rst @@ -0,0 +1,71 @@ + Payroll manager +########################################################## + +|codebuild| + +This is a simple system to keep a record of employees where they will perform different tasks within the company and will be paid accordingly in a monthly bases. + +.. contents:: + +Getting started +----------------- + +The system requires the following: + - Ubuntu 16.04 + - php 7.0 + - composer + - docker + - docker-compose + - mysql 5.7 + +Installation +----------------- + +Alternatively to installing all the packages and configuring the server it's possible to start up an instance of the system with docker-compose + +To install docker +.. code-block:: bash + + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + + sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + + sudo apt-get update + + apt-cache policy docker-ce + + sudo apt-get install -y docker-ce + +To install docker compose +.. code-block:: bash + sudo curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose + + sudo chmod +x /usr/local/bin/docker-compose + +And finally the containers can be initialized by running + +.. code-block:: bash + sudo docker-compose up --build -d + +Sign in +----------------- + +The login page can be accessed at **http://localhost:8085/public/html/login.php** + +To access the platform the user is **sloth** and the pasword **slothness** + +Further reading +----------------- +To further read about the api and it's front-end +`api-payroll `_ + +More about the database `database `_ + + +Data volumes +----------------- +Since the application is designed to run within containers a number of volumes has been created to persist the data, they can be found in the volumes directory on the root of the project + +.. |codebuild| image:: https://s3.amazonaws.com/codefactory-us-east-1-prod-default-build-badges/passing.svg + :target: https://codebuild.us-east-1.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiWm42eW80VzA2OXRTc2xIMXErZ1hlS1RpNnFCaDVMWENqSSsyU2x3dUpReEpCRUtaZGRmbklYaFN0anVEWW9NaGYvQ21PNk9tR25rZGtZMjNvR1ArbGdVPSIsIml2UGFyYW1ldGVyU3BlYyI6IjVXYjl3TWZnUVQ1MFZDQ0kiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=master + :alt: Build status of the master branch on amazon codebuild From 0558ce048fd15091822d741b1883bcae5c3c87be Mon Sep 17 00:00:00 2001 From: Jose Pablo Domingo Aramburo Sanchez Date: Thu, 16 Aug 2018 04:01:26 -0600 Subject: [PATCH 5/8] [mod] Switching to rst --- database/README.md | 16 ---------------- database/README.rst | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 16 deletions(-) delete mode 100644 database/README.md create mode 100644 database/README.rst diff --git a/database/README.md b/database/README.md deleted file mode 100644 index c76210c..0000000 --- a/database/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# The database - -#### The system has been built with the idea of running everything from within docker containers and due to that the following behaivor should be expected. - -#### A new docker image with mysql 5.7 will be created when docker-compose is called which will contain the starting scripts to create the database structure and anything else that is requiered to begin working as well as a config file to change the default port that is exposed. - -#### Once this process begins the database will be initialized by running the scripts in alphabetical order in the directory: -``` -/docker-entrypoint-initdb.d -``` - -#### After the database image has been created it'll be accessible by default in the port 3307, the users 'root' and 'sloth' will be usable both of which have the password 12345678 - -## Data persistence - -#### The database details will be stored in the volume mysql-data which is located in the volumes directory at the root of the project. diff --git a/database/README.rst b/database/README.rst new file mode 100644 index 0000000..6521476 --- /dev/null +++ b/database/README.rst @@ -0,0 +1,22 @@ +================ +``The database`` +================ + +.. contents:: + +About the container +-------------------- + +The database container is created in two stages to bypass some limitations with docker, firstly a new image will be created based on the Dockerfile which will be based on mysql 5.7 and it'll be passed the .sql scripts to initialize the database as well as a config file to configure the port that will be exposed. + +Initializing +------------- +When the database is being created as an image it'll take all the scripts in the **/docker-entrypoint-initdb.d** directory and execute them in alphabetical order which will result in the database with its tables and initial data being created. + +Accession +---------- +The newly created container will have two users *root** and **sloth** both of which will have the password **12345678** and it'll be accessible in the port 3307 + +Persistence +----------- +A volume containing the data from **/var/lib/mysql** will be created to persist the information, once its created running the container build again will execute the starting scripts From 9f1a18c557548080a6437c1d6179b4745e440739 Mon Sep 17 00:00:00 2001 From: Jose Pablo Domingo Aramburo Sanchez Date: Thu, 16 Aug 2018 04:04:16 -0600 Subject: [PATCH 6/8] [mod] Fixing the title --- README.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index b1b5b94..18fa55b 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,6 @@ +================= Payroll manager -########################################################## +================= |codebuild| From 502b7b6c0481db6bc63ea6b359709525ff2a6391 Mon Sep 17 00:00:00 2001 From: Jose Pablo Domingo Aramburo Sanchez Date: Thu, 16 Aug 2018 04:27:15 -0600 Subject: [PATCH 7/8] [mod] Switching to rst --- api-payroll/README.md | 43 ------------------------------------------ api-payroll/README.rst | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 43 deletions(-) delete mode 100644 api-payroll/README.md create mode 100644 api-payroll/README.rst diff --git a/api-payroll/README.md b/api-payroll/README.md deleted file mode 100644 index b9c5e38..0000000 --- a/api-payroll/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# The api - -### Database -##### The connection to the database is handled by pdo, it's configuraitions can be in the section mysql in the file -# -``` -src/settings.php -``` - -##### The default configurations for pdo are: -# -``` -PDO::ATTR_EMULATE_PREPARES -``` -###### By default true, to lower the strain on the database by processing the prepare statements on the server side, if cashe performance is desired this option should be changed to fale -# -``` -PDO::ATTR_ERRMODE -``` -###### Set to 'PDO::ERRMODE_EXCEPTION' which will return all mysql errors as exceptions to prevent further execution of the software -# - -``` -PDO::ATTR_DEFAULT_FETCH_MODE -``` -###### Set to 'PDO::FETCH_ASSOC' which will return the query output as an array of associative arrays where the alias or field name will be the key - -### Error handling -##### Should an exception be encountered it'll be caught by a middleware that will form a new response body, returning it with a 500 http code and a json object containing the keys status set to error as well as a message key that will contain the exeption that was raised and caused the error. - -### Sessions -When a user logs into the system a session will be created by apache, handle with its default behaivor by a cookie. - -### Data protection -Encryption has been applied to sensitive data, passwords are protected with with bcrypt and it's configuration can be found in the settings.php file, by default a cost of 12 is used for the hashing as well as a 16 characters randomly generated string (128 bits) as an iv. - -For data that needs to be both read and written such as names AES in mode cbc with 256 block size has been used. - -The reason to have choosen AES is the desire to make the process of securing the data both secure and affordable since many hardware manufacturers already have architectures designed to improce the speed of AES. - -Important note: While in this project the encryption password has been saved into the settings.php file it's adviced that in a real use case it's stored more securely or else where entirely such as a key management service. - -### The endpoints diff --git a/api-payroll/README.rst b/api-payroll/README.rst new file mode 100644 index 0000000..aae395c --- /dev/null +++ b/api-payroll/README.rst @@ -0,0 +1,34 @@ +======= +The api +======= + +.. contents:: + +About +------- +The project has been built with slim in the backed and jquery with bootstrap for the front, both of them share the public folder from which they can be accessed by the general public. + +Auth +------ +The system uses cookie based sessions which are handled by a midleware, have a time to live of 10 minutes and are refreshed each time a new request is made to the api, further more the contents of the session itself has been secured with openssl. + +Database +--------- +To connect to the database pdo is used, its configuration can be found at **src/settings.php** under the mysql section. The following settings are set as default: + **PDO::ATTR_EMULATE_PREPARES** Has been set to true in order to lower the strain on the database by processing the prepare statements on the server side, if cache performance is desired this option should be changed to false + - **PDO::ATTR_ERRMODE** Uses **PDO::ERRMODE_EXCEPTION** which will return all mysql errors as exceptions to prevent further execution of the software + - **PDO::ATTR_DEFAULT_FETCH_MODE** uses **PDO::FETCH_ASSOC** and as such the query ouput system wide is expected as an associative array + +Data protection +---------------- +| Encryption has been applied to sensitive data, passwords are protected with with bcrypt and it's configuration can be found in the settings.php file, by default a cost of 12 is used for the hashing as well as a 16 characters randomly generated string (128 bits) as an iv. + +| For data that needs to be both read and written such as names AES in mode cbc with 256 block size has been used. + +| The reason to have choosen AES is the desire to make the process of securing the data both secure and affordable since many hardware manufacturers already have architectures designed to improce the speed of AES. + +| **Important note**: While in this project the encryption password has been saved into the settings.php file it's adviced that in a real use case it's stored more securely or else where entirely such as a key management service. + +Error handling +--------------- +Should an exception be encountered it'll be caught by a middleware that will form a new response body, returning it with a 500 http code and a json object containing the keys status set to error as well as a message key that will contain the exception that was raised. From 99ec548c839dc14d0583b05073942e549bcec7be Mon Sep 17 00:00:00 2001 From: Jose Pablo Domingo Aramburo Sanchez Date: Thu, 16 Aug 2018 04:28:18 -0600 Subject: [PATCH 8/8] [fix] Indentation --- api-payroll/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api-payroll/README.rst b/api-payroll/README.rst index aae395c..40f32d8 100644 --- a/api-payroll/README.rst +++ b/api-payroll/README.rst @@ -15,7 +15,7 @@ The system uses cookie based sessions which are handled by a midleware, have a t Database --------- To connect to the database pdo is used, its configuration can be found at **src/settings.php** under the mysql section. The following settings are set as default: - **PDO::ATTR_EMULATE_PREPARES** Has been set to true in order to lower the strain on the database by processing the prepare statements on the server side, if cache performance is desired this option should be changed to false + - **PDO::ATTR_EMULATE_PREPARES** Has been set to true in order to lower the strain on the database by processing the prepare statements on the server side, if cache performance is desired this option should be changed to false - **PDO::ATTR_ERRMODE** Uses **PDO::ERRMODE_EXCEPTION** which will return all mysql errors as exceptions to prevent further execution of the software - **PDO::ATTR_DEFAULT_FETCH_MODE** uses **PDO::FETCH_ASSOC** and as such the query ouput system wide is expected as an associative array