/fs-intake-module

Module for intake of special use applications for Forest Service Application Permits

Primary LanguageTypeScriptOtherNOASSERTION

FS ePermit API CircleCI GitHub Issues

U.S. Forest Service Intake Module

Module for intake of special use applications for Forest Service Application Permits.

Welcome

The U.S. Forest Service is engaged in an ongoing effort to modernize and simplify their permitting processes. One facet of this effort is to make special use permits available to obtain online. Flexion worked with GSA's Technology Transformation Service's Office of Acquisitions and the Forest Service to build out this platform for noncommercial and temporary use permits.

Opportunity Statement

The opportunity statement = the problem we are trying to solve with the ePermitting project

We had the opportunity to modernize the ability to apply for special use permits within a pilot forest (Mt. Baker-Snoqualime) of the Forest Service. Our belief is that this will simplify and speed up the ability to apply for and act on special use permits.

Development

Contributing

See CONTRIBUTING for additional information.

Public domain

This project is in the worldwide public domain. As stated in CONTRIBUTING:

This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.

All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.

U.S. Forest Service intake module development

Requirements:

Package Manager

Install yarn package manager

Node

Install Node ^6.10.3

Git

Install Git

Clone the repository

git clone [repository url] fs-intake-module

Navigate to cloned repo

cd fs-intake-module

Server development

Database

A running Postgresql database is required in order to run the server locally. Please make sure you have installed Postgresql locally and created a database for this project.

Environment Variables

There are environment variables that are required to be set in order to run tests and to run the server in general. Please set up these environment variables either in your shell or on the command line.

In general setting an environment variable in your shell is similar to:

export ENV_VAR=something

and on the command line as part of a command:

ENV_VAR=something ANOTHER_ENV_VAR=somethingelse <rest of command>

The following environment variables are required to run the application locally or with CircleCI:

In order to pass end to end tests locally or on CircleCI, you must include valid s3 credentials in the VCAP_SERVICES variable.

DATABASE_URL

postgres://<user>:<pass>@localhost:<port>/<dbname>

or for CircleCI

postgres://ubuntu:@127.0.0.1:5432/circle_test

PLATFORM

local

or for CircleCI

CI

SNYK_TOKEN

(from https://snyk.io/account)

VCAP_APPLICATION

{"uris":["http://localhost:8080"]}

VCAP_SERVICES

{
  "user-provided": [
    {
      "credentials": {
        "middlelayer_base_url": "https://fs-middlelayer-api-staging.app.cloud.gov/",
        "middlelayer_password": "",
        "middlelayer_username": ""
      },
      "label": "user-provided",
      "name": "middlelayer-service",
      "syslog_drain_url": "",
      "tags": [],
      "volume_mounts": []
    },
    {
      "credentials": {
        "intake_client_base_url": "http://localhost:4200",
        "intake_password": "",
        "intake_username": "",
        "jwt_secret": "shhhhhhhh!"
      },
      "label": "user-provided",
      "name": "intake-client-service",
      "syslog_drain_url": "",
      "tags": [],
      "volume_mounts": []
    },
    {
      "credentials": {
        "entrypoint": "",
        "issuer": "",
        "private_key": "",
        "discovery_url": "https://secure.login.gov/.well-known/openid-configuration",
        "idp_username": "",
        "idp_password": "",
        "jwk": {
          "d": "1234",
          "dp": "1234",
          "dq": "1234",
          "e": "1234",
          "kty": "RSA",
          "kid": "1234",
          "n": "1234",
          "p": "1234",
          "q": "1234",
          "qi": "1234"
        }
      },
      "label": "user-provided",
      "name": "login-service-provider",
      "syslog_drain_url": "",
      "tags": [],
      "volume_mounts": []
    },
    {
      "credentials": { "whitelist": [], "issuer": "", "entrypoint": "", "cert": "", "private_key": "" },
      "label": "user-provided",
      "name": "eauth-service-provider",
      "syslog_drain_url": "",
      "tags": [],
      "volume_mounts": []
    },
    {
      "credentials": { "smtp_server": "", "username": "" },
      "label": "user-provided",
      "name": "smtp-service",
      "syslog_drain_url": "",
      "tags": [],
      "volume_mounts": []
    },
    {
      "name": "auth-service",
      "credentials": { "jwt_secret_key": "shhhhhhhh!" }
    }
  ],
  "s3": [
    {
      "name": "intake-s3",
      "credentials": { "bucket": "", "access_key_id": "", "region": "us-east-1", "secret_access_key": "" }
    }
  ]
}
Install dependencies

run cd server then run yarn to install dependencies.

Available commands

To run any of the server commands, either the environment variables above must be available in your shell or on the command line, and you must be in the server directory.

Setup database

To setup the database run yarn migrate

Start the server

Run yarn dev to start the server, and visit http://localhost:8080.

Other commands

To revert the last database migration run

yarn undoLastMigrate

To revert all of the database migrations and start with a blank database run

yarn undoAllMigrate

To run eslint for linting:

yarn lint

The linting results will be put into server/lint-results.html.

To run all of the tests locally, be sure your Postgresql server is running and then run: yarn test

To run code coverage locally, be sure your Postgresql server is running then run:

yarn coverage

The coverage results can be found in server/coverage/index.html

Server API Documentation

With your local Node server running, browse to http://localhost:8080/docs/api in order to view the interactive Swagger API documentation. This documentation will allow interactive access to the API endpoints.

Authentication

Public users must authenticate with login.gov, and Forest Service admins must authenticate with USDA eAuth. Both of these authentication techniques are handled by the Passport library for Node.js.

Login.gov uses the openid-client passport plugin for the OpenID Connect protocol, and USDA eAuth uses the passport-saml plugin for the SAML protocol.

Due to security restrictions testing can't be done locally, you must use a server on cloud.gov. Setting the PLATFORM environment variable will bypass all authentication checks.

Frontend Development

Install angular cli

Run yarn global add @angular/cli

Navigate to frontend directory

cd frontend

Install dependencies

Run yarn

Development server

Run ng serve for a development server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Build

Run ng build --prod --env=prod --aot=false to build the static files for the single paged app. The build artifacts that can be deployed will be stored in the dist/ directory.

Running unit tests

Run ng test to execute the unit tests via Karma.

Add --code-coverage flag to print out code coverage statistics.

Running end-to-end tests

Run yarn run e2e to execute the end-to-end tests via Protractor.

Typedoc

Build typedoc

Install typedoc globally: yarn global add typedoc

cd frontend

build typedoc yarn run docs

typedoc are added to frontend/src/assets/typedoc and are accessible via url at /assets/typedoc/index.html

Navigate to /assets/typedoc/index.html

Enable html5 pushstate on cloud.gov

In order to enable pushstate for single page apps on cloud.gov using the static build pack, you must add a file called Staticfile to the root directory with a single line pushstate: enabled

This allows you to use urls like /some/path instead of /#/some/path

Reference

SMTP relay configuration for sending emails

The current configuration implements email via google smtp relay. Follow the documentation at https://support.google.com/a/answer/2956491?hl=en to set up your google SMTP relay.

Authentication is set up to support whitelisted IP addresses that are allowed to send emails, so no SMTP authentication is required.

The smtpserver value in your VCAP_SERVICES should be smtp-relay.gmail.com

Docker Environment

As an alternative to installing all the development tools necessary to run the entire environment on your computer, Docker can be used instead. These instructions will detail how to use Docker to setup a full environment to run the application.

  1. Install Docker for your platform at https://www.docker.com/. Make sure that the Docker service is started.

  2. Clone this repository.

  3. In a console terminal navigate to the directory the repository was cloned to. Now cd to the docker directory.

    $ cd fs-intake-module
    $ cd docker
    
  4. Now use Docker Compose to build and start the containers.

    $ docker-compose up --build --force-recreate
    
  5. The first time the containers are created it will take a few minutes. There will be a whole lot of output to the screen, but eventually the output will stop and something like the following should be displayed:

    fs-intake-frontend_1  | webpack: Compiled successfully.
    
  6. The containers and servers are now running. There are four containers:

    • fs-intake-frontend - This container runs the Angular application. It can be accessed in the browser at http://localhost:4200.

    • fs-intake-server - This container runs the server side Node application. It can be accessed in the browser at http://localhost:8080.

    • fs-intake-postgres - This container runs the PostgreSQL database server.

    • adminer - This container runs a PHP based database administration application. It can be accessed at http://localhost:8081. The front page for Adminer is a database login page. The values to use are:

      • System: PostgreSQL
      • Server: fs-intake-postgres:5432
      • Username: postgres
      • Password: postgres
      • Database: postgres
  7. Changes made to any of the JavaScript code will be automatically picked up and the appropriate server will auto-reload so that your changes can be seen immediately.

  8. If either of the package.json files are modified, at this time simply Ctrl+C in the terminal you ran docker-compose in to stop the running containers and then re-run the docker-compose command to rebuild the containers.

Docker Troubleshooting

Known technical Debt

The file frontend/src/sass/_focus-fix.scss implements a style fix in the upstream repository: https://github.com/18F/web-design-standards/pull/2112/files Eventually once these changes are released we can remove this file.

Usability testing

While developing we spent time usability testing features with the correct users and applied majority feedback.

This repository includes usability testing conducted by Flexion