{"id":19269109,"url":"https://github.com/studiowebux/keycloak-experimentation","last_synced_at":"2026-04-07T20:31:57.927Z","repository":{"id":220640134,"uuid":"751155407","full_name":"studiowebux/keycloak-experimentation","owner":"studiowebux","description":"Experimenting with keycloak, postgresDB, NodeJS, PassportJS, OpenID, ExpressJS, Session and hopefully more !","archived":false,"fork":false,"pushed_at":"2024-02-04T08:31:08.000Z","size":889,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T20:12:04.870Z","etag":null,"topics":["discord","docker","express","expressjs","github","keycloak","nodejs","openid","passportjs","postgres"],"latest_commit_sha":null,"homepage":"","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/studiowebux.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-02-01T03:13:04.000Z","updated_at":"2024-10-10T02:07:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"bc8a4f28-bfe6-4694-8e20-1bb3545ef092","html_url":"https://github.com/studiowebux/keycloak-experimentation","commit_stats":null,"previous_names":["studiowebux/keycloak-experimentation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/studiowebux/keycloak-experimentation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studiowebux%2Fkeycloak-experimentation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studiowebux%2Fkeycloak-experimentation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studiowebux%2Fkeycloak-experimentation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studiowebux%2Fkeycloak-experimentation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/studiowebux","download_url":"https://codeload.github.com/studiowebux/keycloak-experimentation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studiowebux%2Fkeycloak-experimentation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31528337,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["discord","docker","express","expressjs","github","keycloak","nodejs","openid","passportjs","postgres"],"created_at":"2024-11-09T20:18:32.061Z","updated_at":"2026-04-07T20:31:57.898Z","avatar_url":"https://github.com/studiowebux.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Step 1 - Generate Self Signed Certificate\n\n```bash\nmkdir -p ~/keycloak/conf/\n\nkeytool -genkeypair -storepass change-this-password -storetype PKCS12 -keyalg RSA -keysize 2048 -dname \"CN=server\" -alias server -ext \"SAN:c=DNS:localhost,IP:127.0.0.1\" -keystore ~/keycloak/conf/server.keystore\n```\n\n**Source**\n\n- https://www.keycloak.org/server/enabletls\n- https://www.keycloak.org/server/containers#_writing_your_optimized_keycloak_dockerfile _(Self signed certificate)_\n\n# Step 2 - Download Discord Provider (Optional)\n\n```bash\nmkdir -p ~/keycloak/providers\n\ncurl -L https://github.com/wadahiro/keycloak-discord/releases/download/v0.5.0/keycloak-discord-0.5.0.jar -o ~/keycloak/providers/keycloak-discord-0.5.0.jar\n```\n\n# Step 3 - Update the keycloak/docker-compose.yml\n\nYou should change all username and password.\nReview the Ports as well.\n\n# Step 4 - Deploy the Stack\n\n```bash\npushd keycloak/\ndocker compose up -d\npopd\n```\n\n# Step 5 - Access keycloak UI\n\nUsing the information you provided at Step 3, go to `https://localhost:8443`\nit will warn you about the self signed certificate, you can allow it.\n\nOpen the administrative console and login.\n\n# Step 6 - Create a Realm\n\n1. Click on `Master` at the top left. Then choose `Create Realm`.\n2. In this example the realm identifier will be: `Studiowebux`.\n3. Select the newly created realm to do the following step.\n4. Navigate to `https://localhost:8443/admin/master/console/#/studiowebux/realm-settings/login`\n5. Enable the `user registration` and `Forgot password`\n\n# Step 7 - Create a client for the NodeJS Application\n\n1. Click `Clients`\n2. Click `Create Client`\n3. I will use `nodejs` as the `client id`\n4. Enable `Client Authentication` and `Authorization`\n5. For the `Authentication flow`, check `Standard flow` and `Direct access grants`\n6. For the `Root URL`, `Home URL`, enter: `http://localhost:3000`\n7. For the `Valid redirect URIs`, enter: `http://localhost:3000/auth/callback`\n8. For the `Valid post logout redirect URIs`, enter: `http://localhost:3000/auth/logout/callback`\n9. For the `Web origins`, enter `http://localhost:3000` as it will serve the HTML pages as well.\n\n# Step 8 - Add Github Identity Provider\n\n**Keycloak:**\n\n1. Click `Identity providers`\n2. Select `Github`\n3. The `Redirect URI` must be copied to the **_step 5_** in the **Github** section.\n4. Enable the `Enable Device Flow`\n5. Click `Register application`\n\n**Github:**\n\n1. Navigate to `github` \u003e `Settings` \u003e `Developer settings` \u003e `OAuth Apps` (https://github.com/settings/developers)\n2. Click `New OAuth App`\n3. For the `Application name`, enter: `keycloak`\n4. For the `Homepage URL`, enter: `http://localhost:3000`\n5. For the `Authorization callback URL`, paste the **Redirect URI** from the **keycloak** step.\n\n**Keycloak:**\n\n1. Copy the `Client Id` from **Github** to the `Client Id` in **keycloak**\n2. Click `Generate a new client secret` on **Github** and copy the value to the `client secret` in **keycloak**\n\n# Step 9 - Add Discord Authentication\n\n**Keycloak:**\n\n1. Click `Identity providers`\n2. Select `Discord`\n3. The `Redirect URI` must be copied to the **_step 4_** in the **Discord** section.\n\n**Discord:**\n\n1. Navigate to `https://discord.com/developers/applications/`\n2. Create an `application`\n3. Click `OAuth2`\n4. Set the `redirects`, copy the value from `Redirect URI` in **Keycloak**\n\n**Keycloak:**\n\n1. Copy the `Client id` from **Discord** to `Client ID` in **Keycloak**\n2. Copy the `Client secret` from **Discord** (_you might have to click `Reset Secret`_) to `Client ID` in **Keycloak**\n\n# Step 10 - Setting up the nodejs application\n\n**Getting Started:**\n\n```bash\ncd nodejs\n\nnpm install\nnpm run start\n```\n\nGo to : `http://localhost:3000`\nClick on every button !  \n\n**Initial setup:**\n\n```bash\npushd nodejs/\n\nnpm install --save \\\n    express \\\n    openid-client \\\n    passport \\\n    express-session\n\nnpm install --save-dev \\\n    nodemon \\\n    dotenv \\\n    dotenv-cli \\\n    eslint \\\n    prettier \\\n    eslint-config-prettier \\\n    eslint-plugin-prettier\n\ncat package.json \\\n    | jq -r '. + {\n        \"type\": \"module\",\n        \"scripts\": {\n            \"start\": \"dotenv -c - npx nodemon\"\n        }\n    }' | tee package.json\n\ncat \u003c\u003cEOF \u003e nodemon.json\n{\n  \"watch\": [\"src\", \".env\"],\n  \"ext\": \".js\",\n  \"ignore\": [],\n  \"exec\": \"node ./src/index.js\"\n}\nEOF\n\ncat \u003c\u003cEOF \u003e .eslintignore\nnode_modules\ndist\nEOF\n\ncat \u003c\u003cEOF \u003e .gitignore\nnode_modules\nEOF\n\ncat \u003c\u003cEOF \u003e .prettierrc\n{\n  \"semi\": true,\n  \"trailingComma\": \"none\",\n  \"singleQuote\": true,\n  \"printWidth\": 80\n}\nEOF\n\nmkdir src/\ntouch src/index.js\ntouch .env\n```\n\n**Setup the .env file**\n\n```dotenv\nNODE_ENV=\"development\"\n\nKEYCLOAK_ISSUER=\"\"\nKEYCLOAK_CLIENT_ID=\"\"\nKEYCLOAK_CLIENT_SECRET=\"\"\nKEYCLOAK_REDIRECT_URIS=\"\"\nKEYCLOAK_LOGOUT_REDIRECT_URIS=\"\"\nKEYCLOAK_RESPONSE_TYPES=\"\"\n\nEXPRESS_SESSION_SECRET=\"\"\n\nEXPRESS_PORT=3000\nEXPORT_HOSTNAME=0.0.0.0\n\nNODE_TLS_REJECT_UNAUTHORIZED=0\n```\n\n# Errors and Solutions\n\n```text\nError: did not find expected authorization request details in session, req.session[\"oidc:localhost\"] is undefined\n```\n\nSet the `NODE_ENV=\"development\"` and restart the server. Go to `http://localhost:3000` and it should be back on !","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstudiowebux%2Fkeycloak-experimentation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstudiowebux%2Fkeycloak-experimentation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstudiowebux%2Fkeycloak-experimentation/lists"}