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(provider): migrate gitlab provider to ts #4929

Merged
Merged
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
22 changes: 0 additions & 22 deletions packages/next-auth/src/providers/gitlab.js

This file was deleted.

72 changes: 72 additions & 0 deletions packages/next-auth/src/providers/gitlab.ts
@@ -0,0 +1,72 @@
import type { OAuthConfig, OAuthUserConfig } from "."

export interface GitLabProfile extends Record<string, any> {
id: number
username: string
email: string
name: string
state: string
avatar_url: string
web_url: string
created_at: string
bio: string
location?: string
public_email: string
skype: string
linkedin: string
twitter: string
website_url: string
organization: string
job_title: string
pronouns: string
bot: boolean
work_information?: string
followers: number
following: number
local_time: string
last_sign_in_at: string
confirmed_at: string
theme_id: number
last_activity_on: string
color_scheme_id: number
projects_limit: number
current_sign_in_at: string
identities: Array<{
provider: string
extern_uid: string
}>
can_create_group: boolean
can_create_project: boolean
two_factor_enabled: boolean
external: boolean
private_profile: boolean
commit_email: string
shared_runners_minutes_limit: number
extra_shared_runners_minutes_limit: number
}

export default function GitLab<P extends GitLabProfile>(
options: OAuthUserConfig<P>
): OAuthConfig<P> {
return {
id: "gitlab",
name: "GitLab",
type: "oauth",
authorization: {
url: "https://gitlab.com/oauth/authorize",
params: { scope: "read_user" },
},
token: "https://gitlab.com/oauth/token",
userinfo: "https://gitlab.com/api/v4/user",
checks: ["pkce", "state"],
profile(profile) {
return {
id: profile.id.toString(),
name: profile.name ?? profile.username,
email: profile.email,
image: profile.avatar_url,
}
},
options,
}
}