{"id":18539134,"url":"https://github.com/simov/grant-azure","last_synced_at":"2026-03-19T04:58:25.594Z","repository":{"id":48838017,"uuid":"282908842","full_name":"simov/grant-azure","owner":"simov","description":"Azure Function handler for Grant","archived":false,"fork":false,"pushed_at":"2022-01-20T11:27:27.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-15T02:36:44.016Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-27T13:38:09.000Z","updated_at":"2023-03-04T06:05:03.000Z","dependencies_parsed_at":"2022-09-23T22:50:14.849Z","dependency_job_id":null,"html_url":"https://github.com/simov/grant-azure","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/simov/grant-azure","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-azure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-azure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-azure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-azure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simov","download_url":"https://codeload.github.com/simov/grant-azure/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simov%2Fgrant-azure/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28734306,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T17:51:25.893Z","status":"ssl_error","status_checked_at":"2026-01-24T17:50:48.377Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T19:46:28.350Z","updated_at":"2026-01-24T18:31:20.359Z","avatar_url":"https://github.com/simov.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# grant-azure\n\n\u003e _Azure Function handler for **[Grant]**_\n\n```js\nvar grant = require('grant').azure({\n  config: {/*configuration - see below*/}, session: {secret: 'grant'}\n})\n\nmodule.exports = async (context, req) =\u003e {\n  var {redirect, response} = await grant(req)\n  return redirect || {\n    status: 200,\n    headers: {'content-type': 'application/json'},\n    body: JSON.stringify(response)\n  }\n}\n```\n\n\u003e _Also available for [AWS], [Google Cloud], [Vercel]_\n\n\u003e _[ES Modules and TypeScript][grant-types]_\n\n---\n\n## Configuration\n\nThe `config` key expects your [**Grant** configuration][grant-config].\n\n### proxies.json\n\nIt is required to set the following `requestOverrides` for Grant:\n\n```json\n{\n  \"$schema\": \"http://json.schemastore.org/proxies\",\n  \"proxies\": {\n    \"oauth\": {\n      \"matchCondition\": {\n        \"route\": \"{*proxy}\"\n      },\n      \"requestOverrides\": {\n        \"backend.request.querystring.oauth_code\": \"{backend.request.querystring.code}\",\n        \"backend.request.querystring.code\": \"\"\n      },\n      \"backendUri\": \"http://localhost/{proxy}\"\n    }\n  }\n}\n```\n\n---\n\n## Routes\n\nYou login by navigating to:\n\n```\nhttps://[APP].azurewebsites.net/connect/google\n```\n\nThe redirect URL of your OAuth app have to be set to:\n\n```\nhttps://[APP].azurewebsites.net/connect/google/callback\n```\n\nAnd locally:\n\n```\nhttp://localhost:3000/connect/google\nhttp://localhost:3000/connect/google/callback\n```\n\n---\n\n## Session\n\nThe `session` key expects your session configuration:\n\nOption | Description\n:- | :-\n`name` | Cookie name, defaults to `grant`\n`secret` | Cookie secret, **required**\n`cookie` | [cookie] options, defaults to `{path: '/', httpOnly: true, secure: false, maxAge: null}`\n`store` | External session store implementation\n\n#### NOTE:\n\n- The default cookie store is used unless you specify a `store` implementation!\n- Using the default cookie store **may leak private data**!\n- Implementing an external session store is recommended for production deployments!\n\nExample session store implementation using [Firebase]:\n\n```js\nvar request = require('request-compose').client\n\nvar path = process.env.FIREBASE_PATH\nvar auth = process.env.FIREBASE_AUTH\n\nmodule.exports = {\n  get: async (sid) =\u003e {\n    var {body} = await request({\n      method: 'GET', url: `${path}/${sid}.json`, qs: {auth},\n    })\n    return body\n  },\n  set: async (sid, json) =\u003e {\n    await request({\n      method: 'PATCH', url: `${path}/${sid}.json`, qs: {auth}, json,\n    })\n  },\n  remove: async (sid) =\u003e {\n    await request({\n      method: 'DELETE', url: `${path}/${sid}.json`, qs: {auth},\n    })\n  },\n}\n```\n\n---\n\n## Handler\n\nThe Azure Function handler for Grant accepts:\n\nArgument | Type | Description\n:- | :- | :-\n`req` | **required** | The request object\n`state` | optional | [Dynamic State][grant-dynamic-state] object `{dynamic: {..Grant configuration..}}`\n\nThe Azure Function handler for Grant returns:\n\nParameter | Availability | Description\n:- | :- | :-\n`session` | Always | The session store instance, `get`, `set` and `remove` methods can be used to manage the Grant session\n`redirect` | On redirect only | HTTP redirect controlled by Grant, your function have to return this object when present\n`response` | Based on transport | The [response data][grant-response-data], available for [transport-state][example-transport-state] and [transport-session][example-transport-session] only\n\n---\n\n## Examples\n\nExample | Session | Callback λ | Routing\n:- | :- | :- | :-\n`transport-state` | Cookie Store | ✕ | {*proxy}\n`transport-querystring` | Cookie Store | ✓ | /connect/{provider}/callback\n`transport-session` | Firebase Session Store | ✓ | /connect/{provider}/callback\n`dynamic-state` | Firebase Session Store | ✕ | {*proxy}\n\n\u003e _Different routing configurations and session store types were used for example purposes only._\n\n#### Configuration\n\nAll variables at the top of the [`Makefile`][example-makefile] with value set to `...` have to be configured:\n\n- `subscription_id` - Subscription ID\n- `tenant_id` - Azure AD Tenant ID\n- `client_id` - Azure AD Client ID\n- `client_secret` - Azure AD Client Secret\n\n- `user` - Publish Profile User Name\n- `pass` - Publish Profile Password\n\n- `firebase_path` - [Firebase] path of your database, required for [transport-session][example-transport-session] and [dynamic-state][example-dynamic-state] examples\n\n```\nhttps://[project].firebaseio.com/[prefix]\n```\n\n- `firebase_auth` - [Firebase] auth key of your database, required for [transport-session][example-transport-session] and [dynamic-state][example-dynamic-state] examples\n\n```json\n{\n  \"rules\": {\n    \".read\": \"auth == '[key]'\",\n    \".write\": \"auth == '[key]'\"\n  }\n}\n```\n\nAll variables can be passed as arguments to `make` as well:\n\n```bash\nmake plan example=transport-querystring ...\n```\n\n#### Dockerfile\n\nRunning the [transport-session][example-transport-session] and the [dynamic-state][example-dynamic-state] examples locally requires your [Firebase] credentials to be set in the `Dockerfile` as well:\n\n```Dockerfile\nENV FIREBASE_PATH=...\nENV FIREBASE_AUTH=...\n```\n\n---\n\n## Develop\n\n```bash\n# build example locally\nmake build-dev\n# run example locally\nmake run-dev\n```\n\n---\n\n## Deploy\n\n```bash\n# build Grant for deployment\nmake build-grant\n# build Grant for transport-querystring and transport-session examples\nmake build-callback\n# deploy Grant\nmake deploy\n```\n\n```bash\n# execute only once\nmake init\n# plan for deployment\nmake plan\n# apply plan for deployment\nmake apply\n# cleanup resources\nmake destroy\n```\n\n---\n\n  [Grant]: https://github.com/simov/grant\n  [AWS]: https://github.com/simov/grant-aws\n  [Azure]: https://github.com/simov/grant-azure\n  [Google Cloud]: https://github.com/simov/grant-gcloud\n  [Vercel]: https://github.com/simov/grant-vercel\n\n  [cookie]: https://www.npmjs.com/package/cookie\n  [Firebase]: https://firebase.google.com/\n\n  [grant-config]: https://github.com/simov/grant#configuration\n  [grant-dynamic-state]: https://github.com/simov/grant#dynamic-state\n  [grant-response-data]: https://github.com/simov/grant#callback-data\n  [grant-types]: https://github.com/simov/grant#misc-es-modules-and-typescript\n\n  [example-makefile]: https://github.com/simov/grant-azure/tree/master/Makefile\n  [example-transport-state]: https://github.com/simov/grant-azure/tree/master/examples/transport-state\n  [example-transport-querystring]: https://github.com/simov/grant-azure/tree/master/examples/transport-querystring\n  [example-transport-session]: https://github.com/simov/grant-azure/tree/master/examples/transport-session\n  [example-dynamic-state]: https://github.com/simov/grant-azure/tree/master/examples/dynamic-state\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimov%2Fgrant-azure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimov%2Fgrant-azure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimov%2Fgrant-azure/lists"}