Skip to content

Commit

Permalink
Merge pull request #25 from FlyersWeb/upgrade
Browse files Browse the repository at this point in the history
Upgrade to Angular 8 and Symfony 4
  • Loading branch information
FlyersWeb committed Nov 19, 2019
2 parents 2392518 + 0c4923d commit 5ccf884
Show file tree
Hide file tree
Showing 172 changed files with 19,085 additions and 19,803 deletions.
24 changes: 1 addition & 23 deletions .gitignore
Expand Up @@ -4,34 +4,12 @@
!/back-end/app/cache/.gitkeep
!/back-end/app/logs/.gitkeep

/back-end/app/check.php

# Cache and logs (Symfony3)
/back-end/var/cache/*
!/back-end/var/cache/.gitkeep
/back-end/var/logs/*
!/back-end/var/logs/.gitkeep

# Parameters
/back-end/app/config/parameters.yml
/back-end/app/config/parameters.ini

# Managed by Composer
/back-end/app/bootstrap.php.cache
/back-end/app/SymfonyRequirements.php
/back-end/var/bootstrap.php.cache
/back-end/bin/*
!bin/console
!bin/symfony_requirements
/back-end/vendor/

# Assets and user uploads
/back-end/vendor/
/back-end/web/bundles/
/back-end/web/uploads/

# Assets managed by Bower
/back-end/web/assets/vendor/

# PHPUnit
/back-end/app/phpunit.xml
/back-end/phpunit.
Expand Down
14 changes: 9 additions & 5 deletions .travis.yml
@@ -1,16 +1,20 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.2
- 7.3

services:
- postgresql

before_script:
- psql -c 'create database symfony_test;' -U postgres
- phpenv config-rm xdebug.ini
- cd back-end
- composer self-update
- composer install
- APP_ENV=test bin/console doctrine:schema:create -q
- APP_ENV=test bin/console doctrine:fixtures:load -q --purge-with-truncate

script:
- phpunit -c app
- phpunit
12 changes: 7 additions & 5 deletions LICENSE
@@ -1,11 +1,13 @@
Copyright (c) 2004-2013 Fabien Potencier
MIT License

Copyright (c) 2020 Nassim Ben Ghmiss

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Expand All @@ -15,5 +17,5 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
58 changes: 38 additions & 20 deletions README.md
@@ -1,51 +1,57 @@
angular-symfony
angular-symfony [![Build Status](https://travis-ci.org/FlyersWeb/angular-symfony.svg?branch=upgrade)](https://travis-ci.org/FlyersWeb/angular-symfony)
===============

Project Bootstrap for an angularJS + Symfony webservices project.
Project Bootstrap for an Angular 2+ and Symfony 4+ webservices project.

Introduction
------------

This project is a template application with secured communication via a RestFul API between the client part with AngularJS and the server part with Symfony2.
This project is a template application with a secured RestFul API communication via WSS UserToken security scheme.

Buy me a coffee
---------------

[![Buy me a coffee](https://raw.githubusercontent.com/FlyersWeb/angular-symfony/upgrade/buy-me-a-coffee.png)](https://paypal.me/nac1dbois)

I'm working on this project in my free time and offering it free of charges. To help me work more on this you send me tips to buy more coffee :)

Installation
------------

Install docker and docker-compose, refer to docker documentation.
Install docker and docker-compose.

Clone the project :

git clone git@github.com:FlyersWeb/angular-symfony.git angular-symfony
git clone git@github.com:FlyersWeb/angular-symfony.git

Launch dockerized environment :

docker-compose up -d
docker-compose up -d

Log in application docker image :

docker exec -it dockerify_application_1 bash
docker-compose exec application bash

Update schemas (FOSUserBundle) :
Install dependencies :

php app/console doctrine:schema:create
composer install

Create and activate user :
Update schemas (FOSUserBundle) :

php app/console fos:user:create admin admin@foo.com admin
php app/console fos:user:activate admin
php bin/console doctrine:schema:create

Clean old nonce if necessary :
Create and activate user :

php app/console escape:wsseauthentication:nonces:delete wsse_secured
php bin/console doctrine:fixtures:load

Access the front end using port 8080 :
Access the front end using port 4200 :

firefox http://localhost:8080 &
firefox http://localhost:4200 &

Authentication system
---------------------

The Authentication system is based on the custom Authentication Provider of the Symfony2 Cookbook : http://symfony.com/doc/2.1/cookbook/security/custom_authentication_provider.html
The Authentication system is based on the custom Authentication Provider of the [Symfony Cookbook](https://symfony.com/doc/4.4/security/custom_authentication_provider.html)

> The following chapter demonstrates how to create a custom authentication provider for WSSE authentication. The security protocol for WSSE provides several security benefits:
> * Username / Password encryption
Expand All @@ -54,14 +60,26 @@ The Authentication system is based on the custom Authentication Provider of the
>
> WSSE is very useful for the securing of web services, may they be SOAP or REST.
I used the exact same authentication system with a little change in moment of generating the digest, we use the hexadecimal value of the hashed seed in lieu of the binary value.
I used the exact same authentication system.

Client Side specifics
---------------------

On the client side, I've inspired my code from Nils Blum-Oeste article explaining how to send an authorization token for every request. To do this you have to register a wrapper for every resource actions that execute a specific code before doing the action. For more information you can check http://nils-blum-oeste.net/angularjs-send-auth-token-with-every--request/.
On the client side, I've inspired my code from Angular official documentation about HttpInterceptor, allowing me to send the WSS UserToken on each HTTP request when token is available. Examples usually shows how to send the Authorization header.

The difference there is that I send the token, username and user digest in the HTTP Header *X-WSSE*.

LICENSE
-------

This program is free software. It comes without any warranty, to the extent permitted by applicable law.

This software is LICENSED under the MIT License. Use it at your own risk.

WARNING
-------

The differences there is that I send the token, username and user digest in the HTTP Header *X-WSSE*.
Servers are configured for developments purposes. Do not deploy this project on production as is. You should have a look to [Symfony deployment documentation](https://symfony.com/doc/4.4/deployment.html) for the Back-end and the [Angular deployment documentation](https://angular.io/guide/deployment) for the Front-End part.

Conclusion
----------
Expand Down
3 changes: 3 additions & 0 deletions back-end/.dockerignore
@@ -0,0 +1,3 @@
app/cache/*
app/logs/*
vendor/*
40 changes: 40 additions & 0 deletions back-end/.env
@@ -0,0 +1,40 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=abb685fe97081c338ed39e8b1cb4bd69
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
#TRUSTED_HOSTS='^localhost|example\.com$'
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11"
# IMPORTANT: You MUST configure your db driver and server version, either here or in config/packages/doctrine.yaml
DATABASE_URL=postgresql://postgres:postgres@database:5432/symfony_dev?serverVersion=10.10
###< doctrine/doctrine-bundle ###

###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=null://localhost
###< symfony/swiftmailer-bundle ###

###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$
###< nelmio/cors-bundle ###
6 changes: 6 additions & 0 deletions back-end/.env.test
@@ -0,0 +1,6 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
DATABASE_URL=postgresql://postgres@localhost:5432/symfony_test?serverVersion=9.2
37 changes: 27 additions & 10 deletions back-end/Dockerfile
@@ -1,22 +1,39 @@
FROM php:5-fpm
FROM php:7-fpm

# Install Composer
RUN apt-get update && apt-get install -y \
openssl \
git \
unzip

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& composer --version

ADD . /var/www
WORKDIR /var/www

RUN usermod -u 1000 www-data
RUN mkdir -p /var/www/app/cache
RUN mkdir -p /var/www/app/logs
RUN chmod -R 777 /var/www/app/cache
RUN chmod -R 777 /var/www/app/logs

RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
&& docker-php-ext-install -j$(nproc) iconv mcrypt \
libpq-dev \
libpng-dev

RUN pecl install mcrypt-1.0.3

RUN docker-php-ext-enable mcrypt \
&& docker-php-ext-install -j$(nproc) iconv \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd pdo_mysql
&& docker-php-ext-install -j$(nproc) gd pdo_pgsql

# Use the default production configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

RUN usermod -u 1000 www-data \
&& mkdir -p /var/www/app/cache \
&& mkdir -p /var/www/app/logs \
&& chmod -R 777 /var/www/app/cache \
&& chmod -R 777 /var/www/app/logs

EXPOSE 9000
CMD ["php-fpm"]
1 change: 0 additions & 1 deletion back-end/app/.htaccess

This file was deleted.

9 changes: 0 additions & 9 deletions back-end/app/AppCache.php

This file was deleted.

42 changes: 0 additions & 42 deletions back-end/app/AppKernel.php

This file was deleted.

14 changes: 0 additions & 14 deletions back-end/app/autoload.php

This file was deleted.

0 comments on commit 5ccf884

Please sign in to comment.