GitLab OAuth provider

OAuth integration for GitLab. Provider id is gitlab.

import { gitlab } from "@lucia-auth/oauth/providers";
import { auth } from "./lucia.js";

const gitlabAuth = gitlab(auth, configs);

gitlab()#

Scope read_user is always included.

const gitlab: (
	auth: Auth,
	configs: {
		clientId: string;
		clientSecret: string;
		redirectUri: string;
		scope?: string[];
		serverUrl?: string;
	}
) => GitlabProvider;
Parameters#
nametypedescriptionoptional
authAuthLucia instance
config.clientIdstringGitLab OAuth app client id
config.clientSecretstringGitLab OAuth app client secret
config.redirectUristringan authorized redirect URI
config.scopestring[]an array of scopes
config.serverUrlstringURL of GitLab, to use a self-managed instance
Returns#
typedescription
GitlabProviderGitLab provider

Interfaces#

GitlabAuth#

See OAuth2ProviderAuth.

// implements OAuth2ProviderAuth<GitlabAuth<_Auth>>
interface GitlabAuth<_Auth extends Auth> {
	getAuthorizationUrl: () => Promise<readonly [url: URL, state: string]>;
	validateCallback: (code: string) => Promise<GitlabUserAuth<_Auth>>;
}
Generics#
nameextendsdefault
_AuthAuthAuth

GitlabTokens#

type GitlabTokens = {
	accessToken: string;
	accessTokenExpiresIn: number;
	refreshToken: string;
};

GitlabUser#

type GitlabUser = {
	id: number;
	username: string;
	email: string;
	name: string;
	state: string;
	avatar_url: string;
	web_url: string;
	created_at: string;
	bio: string;
	public_email: string;
	skype: string;
	linkedin: string;
	twitter: string;
	discord: string;
	website_url: string;
	organization: string;
	job_title: string;
	pronouns: string;
	bot: boolean;
	work_information: string | null;
	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: { 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;
};

GitlabUserAuth#

Extends ProviderUserAuth.

interface GitlabUserAuth<_Auth extends Auth> extends ProviderUserAuth<_Auth> {
	gitlabUser: GitlabUser;
	gitlabTokens: GitlabTokens;
}
propertiestypedescription
gitlabUserGitlabUserGitLab user
gitlabTokensGitlabTokensAccess tokens etc
Generics#
nameextends
_AuthAuth