Skip to content

Latest commit

 

History

History
504 lines (239 loc) · 8.41 KB

AUTHORIZATION.md

File metadata and controls

504 lines (239 loc) · 8.41 KB

Data Authorization

Notice: This file is automatically generated by generate_auth_docs.ts.

Below you will find various diagrams that illustrates how to API restricts access to data.

How it works

This project is hosted behind an Azure API gateway that determines what data can be returned by a given client via subscriptions. Each subscription is tied to a product which modifies the x-auth-group header sent to this service. The available values and filters are defined in the auth.ts file.

// auth.ts
{
  "nml-lab": {},
  "csc": {
    "sites": {
      "where": [
        "healthReg",
        "CSC"
      ]
    }
  },
  "bccdc": {
    "sites": {
      "where": [
        "healthReg",
        "Vancouver"
      ]
    },
    "datasets": {
      "whereIn": [
        "dataID",
        [
          "BCCDC",
          "NML-WWPCR"
        ]
      ]
    }
  },
  "hnj": {
    "sites": {
      "whereIn": [
        "healthReg",
        [
          "Whitehorse",
          "Haines Junction"
        ]
      ]
    },
    "datasets": {
      "whereIn": [
        "dataID",
        [
          "NML-WWPCR",
          "NML-WWGX"
        ]
      ]
    }
  }
}

Authorization flow

The process described above is illustrated below using a flow chart.

Authorization flow chart

SQL Query modifications

When the GraphQL server receives a request to access data in a particular table, the foreign key relationships of the table are examined, and a query plan is produced that enforces the rules declared in auth.ts.

The diagrams below illustrates what the resulting query plan is for each group and table combination.

nml-lab -> addresses

nml-lab addresses query flow

nml-lab -> allSites

nml-lab allSites query flow

nml-lab -> allSitesAdj

nml-lab allSitesAdj query flow

nml-lab -> organizations

nml-lab organizations query flow

nml-lab -> datasets

nml-lab datasets query flow

nml-lab -> Infobase

nml-lab Infobase query flow

nml-lab -> InfobaseTrend

nml-lab InfobaseTrend query flow

nml-lab -> polygons

nml-lab polygons query flow

nml-lab -> instruments

nml-lab instruments query flow

nml-lab -> optionSets

nml-lab optionSets query flow

nml-lab -> setLUs

nml-lab setLUs query flow

nml-lab -> partLUs

nml-lab partLUs query flow

nml-lab -> contacts

nml-lab contacts query flow

nml-lab -> measureSets

nml-lab measureSets query flow

nml-lab -> methodSteps

nml-lab methodSteps query flow

nml-lab -> methodSets

nml-lab methodSets query flow

nml-lab -> languageLUs

nml-lab languageLUs query flow

nml-lab -> translationLUs

nml-lab translationLUs query flow

nml-lab -> sites

nml-lab sites query flow

nml-lab -> samples

nml-lab samples query flow

nml-lab -> measures

nml-lab measures query flow

csc -> addresses

csc addresses query flow

csc -> allSites

csc allSites query flow

csc -> allSitesAdj

csc allSitesAdj query flow

csc -> organizations

csc organizations query flow

csc -> datasets

csc datasets query flow

csc -> Infobase

csc Infobase query flow

csc -> InfobaseTrend

csc InfobaseTrend query flow

csc -> polygons

csc polygons query flow

csc -> instruments

csc instruments query flow

csc -> optionSets

csc optionSets query flow

csc -> setLUs

csc setLUs query flow

csc -> partLUs

csc partLUs query flow

csc -> contacts

csc contacts query flow

csc -> measureSets

csc measureSets query flow

csc -> methodSteps

csc methodSteps query flow

csc -> methodSets

csc methodSets query flow

csc -> languageLUs

csc languageLUs query flow

csc -> translationLUs

csc translationLUs query flow

csc -> sites

csc sites query flow

csc -> samples

csc samples query flow

csc -> measures

csc measures query flow

bccdc -> addresses

bccdc addresses query flow

bccdc -> allSites

bccdc allSites query flow

bccdc -> allSitesAdj

bccdc allSitesAdj query flow

bccdc -> organizations

bccdc organizations query flow

bccdc -> datasets

bccdc datasets query flow

bccdc -> Infobase

bccdc Infobase query flow

bccdc -> InfobaseTrend

bccdc InfobaseTrend query flow

bccdc -> polygons

bccdc polygons query flow

bccdc -> instruments

bccdc instruments query flow

bccdc -> optionSets

bccdc optionSets query flow

bccdc -> setLUs

bccdc setLUs query flow

bccdc -> partLUs

bccdc partLUs query flow

bccdc -> contacts

bccdc contacts query flow

bccdc -> measureSets

bccdc measureSets query flow

bccdc -> methodSteps

bccdc methodSteps query flow

bccdc -> methodSets

bccdc methodSets query flow

bccdc -> languageLUs

bccdc languageLUs query flow

bccdc -> translationLUs

bccdc translationLUs query flow

bccdc -> sites

bccdc sites query flow

bccdc -> samples

bccdc samples query flow

bccdc -> measures

bccdc measures query flow

hnj -> addresses

hnj addresses query flow

hnj -> allSites

hnj allSites query flow

hnj -> allSitesAdj

hnj allSitesAdj query flow

hnj -> organizations

hnj organizations query flow

hnj -> datasets

hnj datasets query flow

hnj -> Infobase

hnj Infobase query flow

hnj -> InfobaseTrend

hnj InfobaseTrend query flow

hnj -> polygons

hnj polygons query flow

hnj -> instruments

hnj instruments query flow

hnj -> optionSets

hnj optionSets query flow

hnj -> setLUs

hnj setLUs query flow

hnj -> partLUs

hnj partLUs query flow

hnj -> contacts

hnj contacts query flow

hnj -> measureSets

hnj measureSets query flow

hnj -> methodSteps

hnj methodSteps query flow

hnj -> methodSets

hnj methodSets query flow

hnj -> languageLUs

hnj languageLUs query flow

hnj -> translationLUs

hnj translationLUs query flow

hnj -> sites

hnj sites query flow

hnj -> samples

hnj samples query flow

hnj -> measures

hnj measures query flow