@ugrc/firebase-auth-arcgis-server-proxy

2.0.7 • Public • Published

firebase-auth-arcgis-server-proxy

An authenticated Firebase function for proxying requests to ArcGIS Server services

Example Usage

import initProxy from 'firebase-auth-arcgis-server-proxy';

const options = {
  host: 'https://my-arcgis-server.com/,
  mappings: [
    {
      from: /^\/toolbox/,
      to: '/arcgis/rest/services/Electrofishing/Toolbox/GPServer',
      secrets: 'ARCGIS_SERVER_CREDENTIALS',
    },
    {
      from: /^\/mapservice/,
      to: '/arcgis/rest/services/Electrofishing/MapService/FeatureServer',
      secrets: 'ARCGIS_SERVER_CREDENTIALS',
    },
    {
      from: /^\/reference/,
      to: '/arcgis/rest/services/Electrofishing/Reference/MapServer',
      secrets: 'ARCGIS_SERVER_CREDENTIALS',
    },
  ],
  claimsCheck: (claims) => {
    if (process.env.FUNCTIONS_EMULATOR) {
      return true;
    }

    return !!claims.firebase?.sign_in_attributes?.customClaim;
  },
};

const [proxy, secrets] = initProxy(options);

export const maps = functions.runWith({ secrets }).https.onRequest(proxy);

host and mappings are required but checkClaims is optional. secrets must match the name of a Firebase Functions secret.

Set option verbose: true to turn on verbose logging.

Readme

Keywords

none

Package Sidebar

Install

npm i @ugrc/firebase-auth-arcgis-server-proxy

Weekly Downloads

13

Version

2.0.7

License

MIT

Unpacked Size

33.1 kB

Total Files

16

Last publish

Collaborators

  • steveoh
  • stdavis