Code Monkey home page Code Monkey logo

cestovne-prikazy's Introduction

Trips management

Application for management of trips.

Getting Started

Application use Google login as only mean of registration/login (google-sign-in). All users must register and be approved by admin before being able to login. For this reason admin user must be seeded into application database. See setup DB chapter to find all necessary information.

All users can be restricted to hosted domain, see Environmental variables.

Prerequisites

  • node 8
  • yarn
  • docker, docker-compose (for database)

Installing

Clone the repository

git clone https://github.com/instea/Cestovne-prikazy.git ; cd Cestovne-prikazy

Start by installing the dependencies:

yarn install

The application needs a running Mongo instance for it to work. It can be pointed to any such instance. It can be set by setting the environment variable MONGO_URL to an url in this format:

mongodb://user:pass@localhost:port/database

If no mongo instance is readily available, the repository contains a docker compose file to quickly start a new instance:

pushd db
docker-compose up -d
popd

No authentication will be used by default. If it is required, read instructions at mongo docker page.

The application also requires some secret files that are not present in the repository:

  • secrets/key.pem - private and public key

Those can be generated by running:

openssl genrsa -out ./secrets/key.pem 2048

and then extracting the Base64 content into private.key and public.pem files.

Setup DB

Database is not initialized with default admin user due to Google login as only mean of user registration and login (you would need to supply google_id and email). Instead of it, create user via Google login and then use following command to grant user with given email admin rights (can approve other users via GUI) and approved status (can login into app).

yarn promote-user --email=<google_email>

Running

If using the dockerized mongo instance with no authentication, the server can be run by this command:

yarn server

Otherwise, mongo url needs to be set:

MONGO_URL=mongodb://user:pass@localhost:port/database yarn server

Environmental variables

When server is running, various environmental variables are used.

Server environmental variables to generate and send emails. When some of SMTP options are not set, emails are not sent.

SMTP_HOST
SMTP_PORT
SMTP_USER
SMTP_PASSWORD
BASE_URL - root url of frontend webpage
APPROVAL_MAIL_RECEIVER - email address to send emails about new leaves to
MAIL_SENDER - name of email sender
DEFAULT_TIMEZONE - default timezone used to format datetime in emails, 
                   if not set, 'Europe/Bratislava' is used

Server environmental variables for Google login. When HOSTED_DOMAIN is set, all users must belong to given hosted domain, otherwise they won't be able to register/login.

HOSTED_DOMAIN=instea.co
CLIENT_ID=914978031481-bk8e8bj1ur0vhq4qlh7n7875drin9r0e.apps.googleusercontent.com

Attendence API

Endpoint to get attendence of users for given year and month (supply month as integer from 1 (January) to 12 (December)) /api/attendence/:year/:month

This endpoint uses following environment variables:

M2M_USERNAME - username for HTTP Basic authentication
M2M_PASSWORD - password for HTTP Basic authentication
SSO_URI      - URI of SSO Metadata endpoint to get all keys for users
SSO_USERNAME - SSO username used for HTTP Basic authentication
SSO_PASSWORD - SSO password used for HTTP Basic authentication

You need to run the client and server application. Client side is run by issuing yarn start command:

yarn start

Client environmental variables for Google login (e.g. in .env.local). When REACT_APP_HOSTED_DOMAIN is set, only emails of given domain are shown in Google login form.

REACT_APP_HOSTED_DOMAIN=instea.co
REACT_APP_CLIENT_ID=914978031481-bk8e8bj1ur0vhq4qlh7n7875drin9r0e.apps.googleusercontent.com

Running the tests

yarn test

Coding style tests

The project uses ESLint for docing style tests. You can run them by:

yarn lint

Automatic fixing can be done by running:

yarn format

Deployment

Build docker

# assumes build env variables are set
docker build --build-arg REACT_APP_HOSTED_DOMAIN --build-arg REACT_APP_CLIENT_ID -t cestaky:master .

# just example: needs -e params to work properly
docker run --rm --name cestaky -v "/$(pwd)/secrets:/opt/app/secrets" -p 4100:4100 cestaky:master

See also

Subproject for leaves management

Built With

cestovne-prikazy's People

Contributors

jansvantner avatar jozefkamensky avatar lmajercik avatar madox2 avatar marek-slavicek avatar matusjuraj avatar misosviso avatar sodik82 avatar

Watchers

 avatar  avatar  avatar  avatar

cestovne-prikazy's Issues

Non-admin user gets error on Trips page

Error while fetching list: GraphQL error: Cannot return null for non-nullable field Trip.user.

Use case:
Create trip with admin, logout, login as (non-admin) user.

Upgrade React + other deps

Two goals:

  • Upgrade React version to latest to be able to use hooks
  • Lot of dependencies are vulnerable (also server side) - minimal effort here (no need to upgrade to latest version, just non-vulnerable version).

Wrong export of leaves

  • Exported (in november) leave - 10/18/18 but actual was Oct 19, 2018 - Oct 19, 2018 (1 work days)

maybe problem with day light saving??

  • Exported (in jan 2019) leave 12/24/18 - 12/31/18 - does not include 31.12. as vacation

Replace traditional login with google sign-in

  • users in DB will be extended with mandatory (non-changeable) email.
  • google signin should use hostedDomain (ie. restriction to domain)
  • registration happens automatically - new user is created
  • DB seeding (first admin) - needs to be able to supply email.
  • first update react (and then angular... might just redirect to react for login).

Upgrade google sign-in

We need to upgrade google sign-in (I believe it is used in both react and angular part)

One or more of your web applications uses the legacy Google Sign-In JavaScript library. Please migrate your project(s) to the new Google Identity Services SDK before March 31, 2023.

Hello Google Developer,

You are receiving this message as a reminder that one or more of your web applications uses the legacy Google Sign-In web solution. Our announced plan stated that support for the Google Sign-In JavaScript platform library will be deprecated after March 31, 2023.

After March 31, 2023, migration to the new Google Identity Services is recommended to sign in customers using their Google Account to your platform. The SDK will use the new Sign in with Google client library.

What do I need to know?

To help you find out which of your web apps or environments are affected, we’re sharing a list of your client ID(s) that use the legacy Google Sign-In web solution. This list should help you evaluate user impact and prioritize the migration work more efficiently:

App Name Client ID
Instea SSO 914978031481-bk8e8bj1ur0vhq4qlh7n7875drin9r0e.apps.googleusercontent.com

What do I need to do?

Please migrate to the new Google Identity Services by following guides for authorization and authentication.

Be sure to read through the Sign in with Google resources guide. If you have migration specific feedback to share, send an email to [email protected]


One or more of your web applications uses the legacy Google Sign-In JavaScript library. Please migrate your project(s) to the new Google Identity Services SDK before March 31, 2023. Hello Google Developer,

You are receiving this message as a reminder that one or more of your web applications uses the legacy Google Sign-In web solution. Our announced plan stated that support for the Google Sign-In JavaScript platform library will be deprecated after March 31, 2023.

After March 31, 2023, migration to the new Google Identity Services is recommended to sign in customers using their Google Account to your platform. The SDK will use the new Sign in with Google client library.

What do I need to know?
To help you find out which of your web apps or environments are affected, we’re sharing a list of your client ID(s) that use the legacy Google Sign-In web solution. This list should help you evaluate user impact and prioritize the migration work more efficiently:

App Name Client ID
Instea SSO 914978031481-bk8e8bj1ur0vhq4qlh7n7875drin9r0e.apps.googleusercontent.com
What do I need to do?
Please migrate to the new Google Identity Services by following guides for authorization and authentication.

Be sure to read through the Sign in with Google resources guide. If you have migration specific feedback to share, send an email to [email protected].

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.