Skip to content
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

feat: add Kobble provider #10386

Open
wants to merge 16 commits 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/2_bug_provider.yml
Expand Up @@ -55,6 +55,7 @@ body:
- "Instagram"
- "Kakao"
- "Keycloak"
- "Kobble"
- "Line"
- "LinkedIn"
- "Mailchimp"
Expand Down
3 changes: 3 additions & 0 deletions docs/static/img/providers/kobble-dark.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/static/img/providers/kobble.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
120 changes: 120 additions & 0 deletions packages/core/src/providers/kobble.ts
@@ -0,0 +1,120 @@
/**
* <div style={{backgroundColor: "#111", display: "flex", justifyContent: "space-between", color: "#fff", padding: 16}}>
* <span>Built-in <b>Kobble</b> integration.</span>
* <a href="https://kobble.io">
* <img style={{display: "block"}} src="https://authjs.dev/img/providers/kobble.svg" height="48" width="48"/>
* </a>
* </div>
*
* @module providers/kobble
*/
import type { OAuthConfig, OAuthUserConfig } from "./index.js"


export interface KobbleProfile {
sub: string;
id: string;
email: string | null;
name: string | null;
picture_url: string | null;
is_verified: boolean;
products: Array<{
id: string;
name: string;
quotas: Array<{
id: string;
name: string;
limit: number;
}>;
}>;
stripe_id: string | null;
updated_at: string;
created_at: string;
}


/**
* Add Kobble login to your page.
*
* ### Setup
*
* #### Callback URL
*
* Authorize this callback URL in your [Kobble application settings](https://kobble.io).
*
* ```
* https://example.com/api/auth/callback/kobble
* ```
*
* #### Configuration
*```js
* import Auth from "@auth/core"
* import Kobble from "@auth/core/providers/kobble"
*
* const request = new Request(origin)
* const response = await Auth(request, {
* providers: [Kobble({ clientId: KOBBLE_CLIENT_ID, clientSecret: KOBBLE_CLIENT_SECRET, tenant: KOBBLE_TENANT })],
* })
* ```
*
* :::tip
* The `tenant` option corresponds to your customer portal domain.
* :::
*
* ### Resources
*
* - [Kobble OAuth documentation](https://docs.kobble.io/product/authentication/overview)
*
* ### Notes
*
* By default, Auth.js assumes that the Kobble provider is
* based on the [OAuth 2](https://www.rfc-editor.org/rfc/rfc6749.html) specification.
*
* :::tip
* Enable the `openid` option in scope if you want to save the users email address on sign up.
* :::
*
* :::tip
*
* The Kobble provider comes with a [default configuration](https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/kobble.ts).
* To override the defaults for your use case, check out [customizing a built-in OAuth provider](https://authjs.dev/guides/providers/custom-provider#override-default-options).
*
* :::
*
* :::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 Kobble<P extends KobbleProfile>(
options: OAuthUserConfig<P> & {
/**
* This corresponds to your customer portal domain.
*/
tenant: string
}
): OAuthConfig<P> {
return {
id: "kobble",
name: "Kobble",
type: "oauth",
authorization: `${options.tenant}/oauth/authorize?scope=read_user`,
token: `${options.tenant}/api/oauth/token`,
userinfo: `${options.tenant}/api/oauth/userinfo`,
checks: ["state"],
profile(profile) {
return {
id: profile.id,
name: profile.name,
email: profile.email,
image: profile.picture_url,
}
},
style: { logo: "/kobble.svg", bg: "#111", text: "#fff" },
...options,
}
}