Add LDAP and OpenID Connect authentication

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/f53b9394-0261-478c-aa14-813efc485813.jpg
This commit is contained in:
alphaeusmote
2025-04-10 02:01:11 +00:00
parent 0699f5acfa
commit 0dc4a0b8cc
5 changed files with 173 additions and 5 deletions
+3 -1
View File
@@ -106,7 +106,7 @@ export const rolePermissions = pgTable("role_permissions", {
};
});
// User schema for local authentication
// User schema for authentication (local, LDAP, or OIDC)
export const users = pgTable("users", {
id: serial("id").primaryKey(),
username: text("username").notNull().unique(),
@@ -114,6 +114,8 @@ export const users = pgTable("users", {
email: text("email"),
fullName: text("full_name"),
roleId: integer("role_id").references(() => roles.id),
authProvider: text("auth_provider").default("local"),
providerUserId: text("provider_user_id"),
createdAt: timestamp("created_at").defaultNow(),
});
+47
View File
@@ -0,0 +1,47 @@
declare module 'passport-ldapauth' {
import { Strategy as PassportStrategy } from 'passport';
export interface LdapAuthOptions {
server: {
url: string;
bindDN?: string;
bindCredentials?: string;
searchBase: string;
searchFilter: string;
searchAttributes?: string[];
tlsOptions?: {
rejectUnauthorized?: boolean;
};
};
usernameField?: string;
passwordField?: string;
passReqToCallback?: boolean;
}
export type VerifyCallback = (
err?: Error | null,
user?: object,
info?: object
) => void;
export type VerifyFunction = (
user: any,
verified: VerifyCallback
) => void;
export type VerifyFunctionWithRequest = (
req: object,
user: any,
verified: VerifyCallback
) => void;
export default class Strategy extends PassportStrategy {
constructor(
options: LdapAuthOptions,
verify?: VerifyFunction | VerifyFunctionWithRequest
);
name: string;
authenticate(req: object, options?: object): void;
}
}
+75
View File
@@ -0,0 +1,75 @@
declare module 'passport-openidconnect' {
import { Strategy as PassportStrategy } from 'passport';
export interface Profile {
id: string;
displayName?: string;
name?: {
familyName?: string;
givenName?: string;
middleName?: string;
};
emails?: Array<{ value: string; type?: string }>;
photos?: Array<{ value: string }>;
username?: string;
_json: any;
_raw: string;
}
export interface StrategyOptions {
issuer?: string;
authorizationURL?: string;
tokenURL?: string;
userInfoURL?: string;
clientID: string;
clientSecret: string;
callbackURL: string;
scope?: string | string[];
passReqToCallback?: false;
}
export interface StrategyOptionsWithRequest {
issuer?: string;
authorizationURL?: string;
tokenURL?: string;
userInfoURL?: string;
clientID: string;
clientSecret: string;
callbackURL: string;
scope?: string | string[];
passReqToCallback: true;
}
export type VerifyCallback = (
err?: Error | null,
user?: object,
info?: object
) => void;
export type VerifyFunction = (
issuer: string,
profile: Profile,
verified: VerifyCallback
) => void;
export type VerifyFunctionWithRequest = (
req: object,
issuer: string,
profile: Profile,
verified: VerifyCallback
) => void;
export class Strategy extends PassportStrategy {
constructor(
options: StrategyOptions,
verify: VerifyFunction
);
constructor(
options: StrategyOptionsWithRequest,
verify: VerifyFunctionWithRequest
);
name: string;
authenticate(req: object, options?: object): void;
}
}