{"id":19301862,"url":"https://github.com/darkness4/auth-htmx","last_synced_at":"2025-04-06T18:13:47.155Z","repository":{"id":179717539,"uuid":"663732647","full_name":"Darkness4/auth-htmx","owner":"Darkness4","description":"Experiment with Go + HTMX and OAuth2/OIDC + WebAuthn","archived":false,"fork":false,"pushed_at":"2025-03-23T18:27:29.000Z","size":347,"stargazers_count":103,"open_issues_count":2,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-30T17:08:31.511Z","etag":null,"topics":["go","htmx","oauth2","oidc","sql","ssr","webauthn"],"latest_commit_sha":null,"homepage":"https://auth-htmx.mnguyen.fr","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Darkness4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-07-08T01:20:58.000Z","updated_at":"2025-03-25T12:14:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"7aadb0e1-afaa-40f4-abd7-60967c9e1dc0","html_url":"https://github.com/Darkness4/auth-htmx","commit_stats":null,"previous_names":["darkness4/auth-htmx"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Darkness4%2Fauth-htmx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Darkness4%2Fauth-htmx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Darkness4%2Fauth-htmx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Darkness4%2Fauth-htmx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Darkness4","download_url":"https://codeload.github.com/Darkness4/auth-htmx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247526760,"owners_count":20953143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["go","htmx","oauth2","oidc","sql","ssr","webauthn"],"created_at":"2024-11-09T23:19:08.521Z","updated_at":"2025-04-06T18:13:47.118Z","avatar_url":"https://github.com/Darkness4.png","language":"Go","readme":"# Go + HTMX + OAuth2/OIDC + WebAuthn\n\nA very simple example HTMX with OAuth2 with:\n\n- Go HTML templating engine.\n- HTMX solution for SSR.\n- OAuth2 with Github Auth and OIDC. OAuth2 delegates authentication to another authentication service. OIDC provides identities.\n- CSRF protection measures for OAuth2 and all requests.\n- SQLite3 with sqlc and golang-migrate.\n- Optional users in database as Identity Provider. Authentication is through WebAuthn, a solution to delegate authentication directly to the user.\n- JWT is used a session token.\n\nEmbellishment:\n\n- Notyf to notify about errors, include HTMX errors.\n- Added Hyperscript for edge cases.\n\n## Motivation\n\nFor the hype.\n\n## Usage\n\n1. Edit the config.yaml to set the OAuth2 providers.\n\n2. Set the necessary parameters or environment variables:\n\n   ```shell\n   ## .env.local\n   ## A 32 bytes hex secret ()\n   CSRF_SECRET=51b22632498f26d9131c4743b72c362567b5b4c96ac5e0f4fef7cb58ecac5684\n   ## A unique string secret\n   JWT_SECRET=secret\n   ## PUBLIC_URL will be used as redirect url which is ${PUBLIC_URL}/callback\n   PUBLIC_URL=http://localhost:3000 # redirectURL: http://localhost:3000/callback\n   DB_PATH=/data/db.sqlite3\n   # CONFIG_PATH=/path/to/config.yaml\n   ```\n\n3. Run the binary:\n\n   ```shell\n   ./auth-htmx\n   ```\n\n**Help**:\n\n```\nNAME:\n   auth-htmx - Demo of Auth and HTMX.\n\nUSAGE:\n   auth-htmx [global options] command [command options] [arguments...]\n\nCOMMANDS:\n   help, h  Shows a list of commands or help for one command\n\nGLOBAL OPTIONS:\n   --csrf.secret value            A 32 bytes hex secret [$CSRF_SECRET]\n   --jwt.secret value             A unique string secret [$JWT_SECRET]\n   --config.path value, -c value  Path of the configuration file. (default: \"./config.yaml\") [$CONFIG_PATH]\n   --public-url value             An URL pointing to the server. (default: \"http://localhost:3000\") [$PUBLIC_URL]\n   --db.path value                SQLite3 database file path. (default: \"./db.sqlite3\") [$DB_PATH]\n   --help, -h                     show help\n   --version, -v                  print the version\n```\n\n## Application Flow\n\n- A home page:\n  - Show login button if not logged in.\n  - Else, show a welcome with routing.\n- A protected counter page.\n\nThe login process follows the standard OAuth2 process, which is fully documented on [GitHub](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps).\n\nFetching identity is through OIDC or GitHub API.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkness4%2Fauth-htmx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarkness4%2Fauth-htmx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkness4%2Fauth-htmx/lists"}