3rww / data-api

A hyper-local environmental and infrastructure data API for the Greater Pittsburgh Area.
Apache License 2.0
2 stars 1 forks source link

3RWW SSO Middleware #24

Open gassc opened 2 years ago

gassc commented 2 years ago

Need middleware and a REST API endpoint to handle authenticating with 3RWW's existing legacy SSO system.

Initially this will be used by the Sewer Atlas v3.

gassc commented 2 years ago

I have the business logic for this middleware worked out in a test Flask app from several years ago.

gassc commented 1 year ago

We can use the existing setup @ atlas.3riverswetweather.org for this. The SSO route can also go get the AGS Token and put it into the session.

gassc commented 1 year ago

See this post for the pattern for accessing secured services with ArcGIS JS API v 4: https://community.esri.com/t5/arcgis-api-for-javascript-questions/how-do-i-pass-token-to-secure-service-using-arcgis/td-p/753271

gassc commented 1 year ago

I've got an endpoint worked up in a Flask app that will do this.

Feed it the src ("3RWW") and the idStr from a successful MDS SSO login:

/mds-atlas-auth/<src>/<idStr>

It returns a JSON response:

{
  "data": {
    "ago": {
      "message": "Not implemented yet.",
      "token": null
    },
    "ags": {
      "message": "3RWW Esri ArcGIS Server token acquired",
      "token": {
        "expires": 1694619433344,
        "token": "..."
      }
    },
    "mds": {
      "authenticated": true,
      "message": {
        "@MESSAGE": "Authentication Successful",
        "USER": {
          "EMAIL": "christian.gass@civicmapper.com",
          "EXPIRES": "9/12/2023 1:03:14 PM",
          "FIRST_NAME": "Christian",
          "LAST_NAME": "Gass",
          "RESULT": "1",
          "ROLE": "2",
          "SESSION": null,
          "UNIQUEID": "2037"
        }
      },
      "token": "0e6e355b-cde2-48b0-a7a1-5093ef4d458b"
    }
  },
  "status": "success"
}

The response JSON has two top level keys: status (one of success, fail, error), and data.

The data object has three things: