Skip to content

Decorates a static web application for use on nav.no

License

Notifications You must be signed in to change notification settings

olofab/pus-decorator

 
 

Repository files navigation

pus-decorator

Decorates a static web application for use on nav.no

supported functionality

pus-decorator comes with much functionality out of the box, but may be deactivated using the following environment variables:

  • DISABLE_DECORATOR
  • DISABLE_PROXY
  • DISABLE_UNLEASH
  • DISABLE_FRONTEND_LOGGER

BETA: Use the environment variabel GZIP_ENABLED in the Dockerfile to turn on gzipping for files: ENV GZIP_ENABLED=true.

usage

use this image as baseimage and set the required configuration parameters. The new image will serve a static web application from index.html found in directory /app with the enabled functionality.

convert your application like this:

https://github.com/navikt/jobbsokerkompetanse/commit/a24450465ee4b49e7772f7739c8249ae95a59a97

configuration

pus-decorator checks for a configuration file at /decorator.yaml unless a different path is explicitly set through the CONFIGURATION_LOCATION environment variable . If either of these files are absent or if some required attributes are undefined, pus-decorator will apply sane and safe default. Using a minimalistic configuration file, only overriding or extending default behaviour is therefore fine.

Please see the example configuration file

typically, you add the following line to the Dockerfile to add decorator.yaml to the docker-container:

ADD decorator.yaml /decorator.yaml

environment variables

in addition to the configuration file the following environment variables are supported:

proxy configuration

Please see the example configuration file

Multiple single page applications

Please see the example configuration file

enforced login

If your application requires the user to be logged in, the pus-decorator can enforce this:

  1. in app-config.yaml, depend on the fasit-resources aad_b2c_clientid and aad_b2c_discovery (see example below)
  2. in app-config.yaml, set the webproxy-flag to true (see example below)
  3. in Dockerfile, set the environment variable OIDC_LOGIN_URL to /veilarbstepup/oidc (see example below)

app-config.yaml:

fasitResources:  
  used:                         
  - alias: aad_b2c_clientid
    resourceType: credential
  - alias: aad_b2c_discovery
    resourceType: baseurl
    
webproxy: true

Dockerfile:

ENV OIDC_LOGIN_URL /veilarbstepup/oidc

/environment.js

endpoint that exposes system properties/environment variables matching this regex: ^PUBLIC_.+. Example:

GET /myapp/environment.js

myapp = window.myapp || {};
myapp['prop2']='content2';
myapp['prop1']='content1';
myapp['MY_ENV_VARIABLE']='tester environment';
myapp['prop']='content';

Feature-evaluation

Two different endpoints that evaluates a list of feature toggles using Unleash.

Example that evaluates toggle-a, toggle-b and toggle-c

GET /myapp/api/feature?feature=toggle-a&feature=toggle-b&feature=toggle-c

Returns application/json

{
    "toggle-b":false,
    "toggle-a":true,
    "toggle-c":false    
}


GET /myapp/api/feature.js?feature=toggle-a&feature=toggle-b&feature=toggle-c

Returns application/javascript

myapp = window.myapp || {};
myapp['toggle-b']=false;
myapp['toggle-a']=true;
myapp['toggle-c']=false;
 

About

Decorates a static web application for use on nav.no

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 97.8%
  • HTML 2.1%
  • Dockerfile 0.1%