mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
* WIP use `Request` and `Response` for core * bump Next.js * rename ts types * refactor * simplify * upgrade Next.js * implement body reader * use `Request`/`Response` in `next-auth/next` * make linter happy * revert * fix tests * remove workaround for middleware return type * return session in protected api route example * don't export internal handler * fall back host to localhost * refactor `getBody` * refactor `next-auth/next` * chore: add `@edge-runtime/jest-environment` * fix tests, using Node 18 as runtime * fix test * remove patch * upgrade/add dependencies * type and default import on one line * don't import all adapters by default in dev * simplify internal endpoint config Instead of passing url and params around as a string and an object, we parse them into a `URL` instance. * assert if both endpoint and issuer config is missing * allow internal redirect to be `URL` * mark clientId as always internally, fix comments * add web-compatible authorization URL handling * fix type * fix neo4j build * remove new-line * reduce file changes in the PR * simplify types * refactor `crypto` usage In Node.js, inject `globalThis.crypto` instead of import * add `next-auth/web` * refactor * send header instead of body to indicate redirect response * fix eslint * fix tests * chore: upgrade dep * fix import * refactor: more renames * wip core * support OIDC * remove `openid-client` * temprarily remove duplicate logos * revert * move redirect logic to core * wip fix css * revert Logo component * output ESM * fix logout * deprecate OAuth 1, simplify internals, improve defaults * refactor providers, test facebook * fix providers * target es2020 * fix CSS * update lock file * make logos optional * sync with `next-auth` * clean up `next-auth/edge` * sync * remove uuid * make secret required in dev * remove todo comments * pass through OAuth client options * generate declaration map * default env secret to AUTH_SECRET * temporary Headers fix * move pages to lib * move errors to lib * move pages/index to lib * move routes to lib * move init to lib * move styles to lib * move types to lib * move utils to lib * fix imports * update ignore/clean patterns * fix imports * update styles ts * update gitignore * update exports field * revert `next-auth` * remove extra tsconfig files * remove `private` from package.json * remove unused file, expose type * move gitignore, reduce exposed types * add back tsconfig files * remove leftover * revert gitignore * remove test script
77 lines
1.7 KiB
TypeScript
77 lines
1.7 KiB
TypeScript
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: "https://gitlab.com/oauth/authorize?scope=read_user",
|
|
token: "https://gitlab.com/oauth/token",
|
|
userinfo: "https://gitlab.com/api/v4/user",
|
|
profile(profile) {
|
|
return {
|
|
id: profile.id.toString(),
|
|
name: profile.name ?? profile.username,
|
|
email: profile.email,
|
|
image: profile.avatar_url,
|
|
}
|
|
},
|
|
style: {
|
|
logo: "/gitlab.svg",
|
|
logoDark: "/gitlab-dark.svg",
|
|
bg: "#fff",
|
|
text: "#FC6D26",
|
|
bgDark: "#FC6D26",
|
|
textDark: "#fff",
|
|
},
|
|
options,
|
|
}
|
|
}
|