Skip to content

A repository with a project on Cybersecurity course, focusing mainly on authorization in web applications. It offers implementation and management of user authorization mechanisms, while providing clear instructions on how to configure and apply authorization in web applications.

Notifications You must be signed in to change notification settings

mkozbial/AuthorizationInWebApps

Repository files navigation

Project setup

Make sure Docker is installed and running on your system before executing any Docker commands. https://docs.docker.com/get-docker/.

Development Environment Setup

For setting up the development environment, you will use Docker Compose to build and manage your services. You have options to start the backend, frontend, or both simultaneously. Here's how you can do it:

Required .env file

Before running the whole build, you need to set environment variables in .env as presented in .env-example file.

Generating JWT Secret

node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

Now you can copy the result and paste into the .env file.

Building Services

To build all the services necessary for the development environment, run the following command in your terminal:

docker-compose build

Starting Services

You can start the services individually or both at once depending on your need:

  • Backend Only

    To start only the backend services in development mode, run:

    make dev-b
  • Frontend Only

    To start only the frontend services in development mode, run:

    make dev-f
  • Both Backend and Frontend

    To start both backend and frontend services simultaneously in development mode, use:

    make dev

Production Environment Setup

Setting up the production environment requires building the frontend assets and the Docker images, followed by launching the services.

Building Frontend Assets

Before building your Docker images in production, ensure that the frontend assets are compiled, use the following command in required directories:

npm run build

Building Services

To build all the services necessary for the production environment, run:

docker-compose build

Starting Services

Like in development, you can start the backend, frontend, or both in production mode:

  • Backend Only

    To deploy only the backend services in production mode, run:

    make prod-b
  • Frontend Only

    To deploy only the frontend services in production mode, run:

    make prod-f
  • Both Backend and Frontend

    To deploy both backend and frontend services simultaneously in production mode, use:

    make prod

Database connection

Installing PostgreSQL

  1. Windows

    • Go to the official PostgreSQL website: Download PostgreSQL.
    • Choose the appropriate version for your operating system and download the installer.
    • Run the installer and follow the instructions to install PostgreSQL.
    • After the installation completes, ensure PostgreSQL has been successfully installed by running either the psql program or pgAdmin.
    • Note: If you want to use psql in the Windows terminal, you need to set the environment variable for PostgreSQL bin directory. This can usually be done during the installation process or manually by updating the system's PATH variable.
  2. Unix/Linux (Ubuntu):

    • Open a terminal.
    • Execute the following commands to install PostgreSQL:
      sudo apt update
      sudo apt install postgresql postgresql-contrib
      
    • After the installation completes, PostgreSQL will automatically start as a service.

PostgreSQL setup

psql -U postgres 

The whole setup is managed by the docker compose, all you have to do is fill the example create your .env file basing of the given example.

Note: When you want to develop locally the host should be named as the database container name.

Creating super user

  1. Enter the backend terminal

  2. Run following script

node createsuperuser.js

Creating firebase super user

  1. Unfortunately right now you have to do it manually

  2. Run following script

node --env-file=.\front\.env .\front\fb_make_super_user.mjs EMAIL

About

A repository with a project on Cybersecurity course, focusing mainly on authorization in web applications. It offers implementation and management of user authorization mechanisms, while providing clear instructions on how to configure and apply authorization in web applications.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •