{"id":21692772,"url":"https://github.com/iad-os/react-ghost-auth","last_synced_at":"2026-02-06T20:03:41.654Z","repository":{"id":57117126,"uuid":"426716810","full_name":"iad-os/react-ghost-auth","owner":"iad-os","description":"React Ghost Auth is an easy to use multi-provider authentication and authorization library. The library uses the OpenID Connect Flow.","archived":false,"fork":false,"pushed_at":"2026-02-05T14:49:17.000Z","size":415,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-06T01:20:46.122Z","etag":null,"topics":["authentication","authorization","keycloak","oauth2","oauth2-client","open-id-connect","react","reactjs","relying-party","token"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/iad-os.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-11-10T17:35:32.000Z","updated_at":"2026-02-05T14:49:21.000Z","dependencies_parsed_at":"2025-04-12T10:49:05.596Z","dependency_job_id":null,"html_url":"https://github.com/iad-os/react-ghost-auth","commit_stats":null,"previous_names":[],"tags_count":116,"template":false,"template_full_name":null,"purl":"pkg:github/iad-os/react-ghost-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iad-os%2Freact-ghost-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iad-os%2Freact-ghost-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iad-os%2Freact-ghost-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iad-os%2Freact-ghost-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iad-os","download_url":"https://codeload.github.com/iad-os/react-ghost-auth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iad-os%2Freact-ghost-auth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29174356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T19:56:27.068Z","status":"ssl_error","status_checked_at":"2026-02-06T19:56:18.934Z","response_time":59,"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":["authentication","authorization","keycloak","oauth2","oauth2-client","open-id-connect","react","reactjs","relying-party","token"],"created_at":"2024-11-25T18:17:18.417Z","updated_at":"2026-02-06T20:03:41.599Z","avatar_url":"https://github.com/iad-os.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Ghost Auth\n\nReact Ghost Auth is an easy to use multi-provider authentication and authorisation library.\nThe library uses the OpenID Connect Flow.\nYou simply set your configurations options for all providers to be used, and use them. It's that simple.\n\n## Author\n\n👤 **Nicola Vurchio**\nGithub: [@nicolavurchio-iad2](https://github.com/nicolavurchio-iad2)\n\n## Installation\n\n```bash\nnpm i @iad-os/react-ghost-auth\n```\n\n## Playground\n\nSee how the library is used here\nGithub: [Ghost Auth Playground](https://github.com/iad-os/ghost-oauth2-playground)\n\n## Usage\n\n##### 1. Create an authConfig file and setup each provider's configuration options.\n\nYou can get the provider options from your chosen provider i.e Google, Keycloak, Microsoft etc.\nNOTE: AuthenticationConfig is solely for type checking\n\n```typescript\nimport { AuthenticationConfig } from '@iad-os/react-ghost-auth';\n\nexport const authConfig: AuthenticationConfig = {\n  providers: {\n    //Options example\n    google: {\n      name: 'google',\n      authorization_endpoint: 'https://accounts.google.com/o/oauth2/auth',\n      token_endpoint: 'https://oauth2.googleapis.com/token',\n      client_id: 'xxxxxxxxxxxxxx.apps.googleusercontent.com',\n      requested_scopes: 'profile email openid',\n      redirect_uri: 'http://localhost:3000/redirect',\n      end_session_endpoint: '',\n      redirect_logout_uri: 'http://localhost:3000',\n      access_type: 'offline',\n      client_secret: 'xxxxxxxxxxxxxxxxxx',\n    },\n\n    keycloak: {\n      //Put options here\n    },\n\n    microsoft: {\n      //Put options here\n    },\n  },\n};\n```\n\n\u0026nbsp;\n\n##### 2. Import the AuthenticationProvider and wrap your App Component\n\n\u0026nbsp;\n\n```typescript\nimport AuthenticationProvider from '@iad-os/react-ghost-auth';\n\n\u003cAuthenticationProvider\n  config={authConfig}\n  axios={axios}\n  onRoute={handleRoute}\u003e\n\n    \u003c/App\u003e // Your app\n\n\u003c/AuthenticationProvider\u003e\n```\n\n\u0026nbsp;\n\n##### 3. Setup login on the UI by importing the useAuthentication hook\n\nThis exposes api's that can be found below i.e Public Api's\n\n```typescript\nimport { useAuthentication } from '@iad-os/react-ghost-auth';\n\nconst Login: React.FC = () =\u003e {\n  const { login } = useAuthentication();\n\n  function handleGoogle() {\n    login(\"google\");\n  }\n\n  function handleKeyCloak() {\n    login(\"keycloak\");\n  }\n\n  return (\n      \u003cButton onClick={handleGoogle}\u003e\n        Login with Google\n      \u003c/Button\u003e\n\n      \u003cButton onClick={handleKeyCloak}\u003e\n        Login with Keycloak\n      \u003c/Button\u003e\n  );\n};\n```\n\n\u0026nbsp;\n\n## Public APIs\n\nThe public api's below are returned from the **useAuthentication** hook\n| API | Purpose |\n| ------ | ------ |\n| login(providerName: string) | A function that initaites the login flow by redirecting the user to the chosen provider |\n| logout() | A function that clears the userInfo and tokenInfo and logs the user out of the app |\n| userInfo() | A function that returns the user information provided by the chosen provider |\n| tokenInfo() | A function that returns the access and refresh tokens|\n| isAuthenticated() | A method that returns true if user is authenticated and false otherwise |\n| status: EStatus | A variable that returns the login state which can be 'INIT', 'LOGIN', 'LOGGING' or 'LOGGED' |\n| changeStatus(status: EStatus) | A function that sets the login state i.e status|\n|providerInfo() | A function that returns the selected provider and default provider if one is provided|\n\n## Components\n\nThe components below can be used as wrappers to trigger preffered behaviour\n| Component | Purpose |\n| ------ | ------ |\n| RequireAuth | A wrapper component that requires user to be authenticated before it's content is exposed|\n| Logging | A wrapper component that exposes its content **while** the log in process is running|\n| Logged | A wrapper component that exposes its content after the log in process is successful|\n| AutoLogin | A wrapper or standalone component that initiates the login process automatically on page/site reload|\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiad-os%2Freact-ghost-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiad-os%2Freact-ghost-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiad-os%2Freact-ghost-auth/lists"}