Skip to content

feat(provider): add Authgear provider #13018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/2_bug_provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ body:
- "Atlassian"
- "Auth0"
- "Authentik"
- "Authgear"
- "Azure Active Directory"
- "Azure Active Directory B2C"
- "Azure DevOps"
Expand Down
1 change: 1 addition & 0 deletions docs/public/img/providers/authgear.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 81 additions & 0 deletions packages/core/src/providers/authgear.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* <div class="provider" style={{backgroundColor: "#000", display: "flex", justifyContent: "space-between", color: "#fff", padding: 16}}>
* <span>Built-in <b>Authgear</b> integration.</span>
* <a href="https://authgear.com/">
* <img style={{display: "block"}} src="https://authjs.dev/img/providers/authgear.svg" height="48" />
* </a>
* </div>
*
* @module providers/authgear
*/
import type { OAuthConfig, OAuthUserConfig } from "./index.js"

export interface AuthgearProfile extends Record<string, any> {
sub: string
name: string
email: string
picture: string
}

/**
* Add Authgear login to your page.
*
* ### Setup
*
* #### Callback URL
* ```
* https://example.com/api/auth/callback/authgear
* ```
*
* #### Configuration
*```ts
* import { Auth } from "@auth/core"
* import Authgear from "@auth/core/providers/authgear"
*
* const request = new Request(origin)
* const response = await Auth(request, {
* providers: [
* Authgear({
* clientId: YOUR_AUTHGEAR_CLIENT_ID,
* clientSecret: YOUR_AUTHGEAR_CLIENT_SECRET,
* issuer: YOUR_AUTHGEAR_ISSUER_OR_PROJECT_ENDPOINT,
* client: {
token_endpoint_auth_method: "client_secret_post",
}
* }),
* ],
* })
* ```
*
* ### Resources
*
* - [Authgear OAuth documentation](https://docs.authgear.com/get-started/regular-web-app)
*
* :::tip
*
* The Authgear provider comes with a [default configuration](https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/authgear.ts).
* To override the defaults for your use case, check out [customizing a built-in OAuth provider](https://authjs.dev/guides/configuring-oauth-providers).
*
* :::
*
* :::info **Disclaimer**
*
* If you think you found a bug in the default configuration, you can [open an issue](https://authjs.dev/new/provider-issue).
*
* Auth.js strictly adheres to the specification and it cannot take responsibility for any deviation from
* the spec by the provider. You can open an issue, but if the problem is non-compliance with the spec,
* we might not pursue a resolution. You can ask for more help in [Discussions](https://authjs.dev/new/github-discussions).
*
* :::
*/
export default function Authgear<P extends AuthgearProfile>(
options: OAuthUserConfig<P>
): OAuthConfig<P> {
return {
id: "authgear",
name: "Authgear",
type: "oidc",
style: { bg: "#000", text: "#fff" },
options,
}
}