Skip to content

Auth Azure

Azure authorization

To get the value of request header x-azure-authorization, use g.req.auth.authAzure.

const azure_auth = g.req.auth.authAzure;

Setting sample object

{
    "authTokenType": "AZURE", 
    "authTokenAzureAD": {
        "appId": "__CLIENT_ID__",
        "tenant": "__TENANT_ID__",
        "audience": "",
        "issuer": "",
        "sourceFieldOfUniqueId": "__TOKEN_OBJECT_FIELD_NAME__",
        "groupsDataSource": {
            "instance": "INSTANCE_NAME",
            "database": "DATABASE_NAME",
            "table": "COLLECTION_NAME",
            "targetFieldForUniqueId": "UNIQUE_COLUMN_NAME",
            "groupsColumn": "COMMA_SEPARATED_GROUPS",
            "select": {
                "COLUMN_NAME1": 1,
                "COLUMN_NAME2": 1
            }
        }
    }
}
  • You will get 'appId', 'tenant', 'audience' and 'issuer' data are from the Azure.
  • The 'sourceFieldOfUniqueId' is the field name which you will get after opening Azure token, mostly it will be "preferred_username" because it holds user email address.
  • Provide the groups name comma separated in the 'groupsColumn' field and provide the 'instance', 'database', 'table' from which that 'groupsColumn' exist.
  • The 'targetFieldForUniqueId' is your database field which contains the exact same value as the 'sourceFieldOfUniqueId' has.
  • In 'select' you can define the column name which you want to get in the response.