{"id":15016439,"url":"https://github.com/rubenrivera/demo-eleventy-serverless-oauth","last_synced_at":"2026-02-20T00:01:38.832Z","repository":{"id":229191810,"uuid":"776065297","full_name":"rubenrivera/demo-eleventy-serverless-oauth","owner":"rubenrivera","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-23T18:04:17.000Z","size":95,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-13T03:45:12.894Z","etag":null,"topics":["eleventy","javascript","netlify","nodejs","nunjucks","oauth2"],"latest_commit_sha":null,"homepage":"https://serene-bonbon-b699e0.netlify.app","language":"JavaScript","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/rubenrivera.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-22T15:58:41.000Z","updated_at":"2024-08-29T19:15:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"4e5c63ab-2321-474d-9621-e97120e59b29","html_url":"https://github.com/rubenrivera/demo-eleventy-serverless-oauth","commit_stats":{"total_commits":77,"total_committers":5,"mean_commits":15.4,"dds":"0.38961038961038963","last_synced_commit":"8f249ed82919525e43fcb5da3db355ed03cd6f64"},"previous_names":["rubenrivera/demo-eleventy-serverless-oauth"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rubenrivera/demo-eleventy-serverless-oauth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenrivera%2Fdemo-eleventy-serverless-oauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenrivera%2Fdemo-eleventy-serverless-oauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenrivera%2Fdemo-eleventy-serverless-oauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenrivera%2Fdemo-eleventy-serverless-oauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubenrivera","download_url":"https://codeload.github.com/rubenrivera/demo-eleventy-serverless-oauth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenrivera%2Fdemo-eleventy-serverless-oauth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29637400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T22:32:43.237Z","status":"ssl_error","status_checked_at":"2026-02-19T22:32:38.330Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["eleventy","javascript","netlify","nodejs","nunjucks","oauth2"],"created_at":"2024-09-24T19:48:52.843Z","updated_at":"2026-02-20T00:01:38.807Z","avatar_url":"https://github.com/rubenrivera.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stack Exchange\nAdd Stack Exchange / Stack Overflow as OAuth provider\n\n[![Netlify Status](https://api.netlify.com/api/v1/badges/caad30d0-7b2e-4788-b499-72b5796cc8f2/deploy-status?branch=main)](https://app.netlify.com/sites/serene-bonbon-b699e0/deploys?branch=main)\n\n# demo-eleventy-serverless-oauth\n\nA demo project using OAuth to secure some of your Eleventy Serverless routes.\n\n* [Demo](https://demo-eleventy-serverless-oauth.netlify.app)\n* [Deploy your own to Netlify](https://app.netlify.com/start/deploy?repository=https://github.com/11ty/demo-eleventy-serverless-oauth)\n\n---\n\n* [Blog post on zachleat.com](https://www.zachleat.com/web/eleventy-login/)\n* [Walk-through on YouTube](https://www.youtube.com/watch?v=At19o2Ox57Y)\n\n## Run locally\n\n```\nnpm install\nnpm run dev\n```\n\nNavigate to http://localhost:8888\n\nThe full login flow is supported on localhost, assuming the Redirect URI set in your OAuth Application is configured correctly.\n\n## OAuth Application Providers\n\nThis example includes Netlify, GitHub, and GitLab providers. If you only want a subset of these providers, just remove the Login buttons that you don’t want and don’t worry about the relevant environment variables for that provider.\n\n1. Create one or more OAuth applications:\n    * [Netlify OAuth](https://app.netlify.com/user/applications/new)\n    * [GitHub OAuth](https://github.com/settings/applications/new)\n    * [GitLab](https://gitlab.com/-/profile/applications)\n    * [Slack](https://api.slack.com/apps) (Redirect URI must be specified in separate Oauth \u0026 Permissions section)\n    * [LinkedIn](https://www.linkedin.com/developers/apps) (To enable this you _must_ 1. create a LinkedIn Company Page and 2. add the [_Sign In With LinkedIn_ product under the Products tab](https://stackoverflow.com/questions/53479131/unauthorized-scope-error-in-linkedin-oauth2-authentication))\n    * [Stack Exchange](https://stackapps.com/apps/oauth/register)\n2. Add the appropriate environment variables to your `.env` file:\n    * Netlify: `NETLIFY_OAUTH_CLIENT_ID` and `NETLIFY_OAUTH_CLIENT_SECRET`\n    * GitHub: `GITHUB_OAUTH_CLIENT_ID` and `GITHUB_OAUTH_CLIENT_SECRET`\n    * GitLab: `GITLAB_OAUTH_CLIENT_ID` and `GITLAB_OAUTH_CLIENT_SECRET`\n    * Slack: `SLACK_OAUTH_CLIENT_ID` and `SLACK_OAUTH_CLIENT_SECRET`\n    * LinkedIn: `LINKEDIN_OAUTH_CLIENT_ID` and `LINKEDIN_OAUTH_CLIENT_SECRET`\n    * Stack Exchange: `STACKEXCHANGE_OAUTH_CLIENT_ID`, `STACKEXCHANGE_OAUTH_CLIENT_SECRET` and `STACKEXCHANGE_KEY`\n\nFor Netlify deployment you'll need to add these environment variables in the Netlify web app by defining them in Settings -\u003e Build \u0026 Deploy -\u003e Environment.\n\nTip: For applications that don’t let you define multiple redirect URIs, I like to set up two OAuth applications: one for production and one for local development. That way I don’t have to worry about juggling the different Redirect URIs in the provider’s web interface. e.g. this will need to be `http://localhost:8888/.netlify/functions/auth-callback` for local development.\n\n## Add this to your Eleventy site\n\nYou will need a:\n* static login form\n* a secure serverless template\n\n### Static login form\n\nDoes not have to be in a serverless template. Put it in a shared header on your site!\n\n```\n\u003cform action=\"/.netlify/functions/auth-before\"\u003e\n  \u003cinput type=\"hidden\" name=\"securePath\" value=\"/YOUR_PATH_HERE/\"\u003e\n  \u003cbutton type=\"submit\" name=\"provider\" value=\"netlify\"\u003eLogin with Netlify\u003c/button\u003e\n  \u003cbutton type=\"submit\" name=\"provider\" value=\"github\"\u003eLogin with GitHub\u003c/button\u003e\n  \u003cbutton type=\"submit\" name=\"provider\" value=\"gitlab\"\u003eLogin with GitLab\u003c/button\u003e\n  \u003cbutton type=\"submit\" name=\"provider\" value=\"slack\"\u003eLogin with Slack\u003c/button\u003e\n  \u003cbutton type=\"submit\" name=\"provider\" value=\"linkedin\"\u003eLogin with Linkedin\u003c/button\u003e\n  \u003cbutton type=\"submit\" name=\"provider\" value=\"stackexchange\"\u003eLogin with Stack Overflow\u003c/button\u003e\n\u003c/form\u003e\n```\n\n`securePath` should contain the URL to the secured serverless template (see next section).\n\n### Serverless Templates\n\nServerless templates can be secured with the following front matter (this example is YAML):\n\n```\n---\npermalink:\n  dynamic: \"/YOUR_PATH_HERE/\"\nsecure:\n  unauthenticatedRedirect: \"/\"\n---\n```\n\nThe above will secure the path and redirect any unauthenticated requests to the URL of your choosing.\n\nYou can also conditionally render content inside of an insecure serverless template. Just check for the `user` global (you can rename this in `netlify/functions/dynamic/index.js`). Here’s an example of that:\n\n```\n---\npermalink:\n  dynamic: \"/YOUR_PATH_HERE/\"\n---\n{% if user %}\nYou are logged in!\n\u003c!-- Show Logout form --\u003e\n{% else %}\n\u003c!-- Show Login form --\u003e\n{% endif %} \n```\n\nYou can see an example of this in [the `everything-serverless` branch](https://github.com/11ty/demo-eleventy-serverless-oauth/compare/everything-serverless).\n\n#### More detail\n\nYou may need to familiarize yourself with [Eleventy Serverless templates](https://www.11ty.dev/docs/plugins/serverless/#usage).\n\nRelevant files:\n* `.eleventy.js` adds the Elventy Serverless bundler plugin for the `dynamic` permalink.\n* Eleventy Serverless `.gitignore` additions: `netlify/functions/dynamic/**` and \n`!netlify/functions/dynamic/index.js`\n* Copy to your project:\n  * `netlify/functions/dynamic/index.js`\n  * `netlify/functions/util/*`\n  * `netlify/functions/auth-before.js`\n  * `netlify/functions/auth-callback.js`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenrivera%2Fdemo-eleventy-serverless-oauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubenrivera%2Fdemo-eleventy-serverless-oauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenrivera%2Fdemo-eleventy-serverless-oauth/lists"}