feat(#413): implement GET /auth/config discovery endpoint
All checks were successful
ci/woodpecker/push/api Pipeline was successful

- Add getAuthConfig() to AuthService (email always, OIDC when enabled)
- Add GET /auth/config public endpoint with Cache-Control: 5min
- Place endpoint before catch-all to avoid interception

Refs #413

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jason Woltje
2026-02-16 11:14:51 -06:00
parent a9090aca7f
commit 2d59c4b2e4
4 changed files with 103 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ describe("AuthController", () => {
const mockAuthService = {
getAuth: vi.fn(),
getNodeHandler: vi.fn().mockReturnValue(mockNodeHandler),
getAuthConfig: vi.fn(),
};
beforeEach(async () => {
@@ -124,6 +125,40 @@ describe("AuthController", () => {
});
});
describe("getConfig", () => {
it("should return auth config from service", () => {
const mockConfig = {
providers: [
{ id: "email", name: "Email", type: "credentials" as const },
{ id: "authentik", name: "Authentik", type: "oauth" as const },
],
};
mockAuthService.getAuthConfig.mockReturnValue(mockConfig);
const result = controller.getConfig();
expect(result).toEqual(mockConfig);
expect(mockAuthService.getAuthConfig).toHaveBeenCalled();
});
it("should return correct response shape with only email provider", () => {
const mockConfig = {
providers: [{ id: "email", name: "Email", type: "credentials" as const }],
};
mockAuthService.getAuthConfig.mockReturnValue(mockConfig);
const result = controller.getConfig();
expect(result).toEqual(mockConfig);
expect(result.providers).toHaveLength(1);
expect(result.providers[0]).toEqual({
id: "email",
name: "Email",
type: "credentials",
});
});
});
describe("getSession", () => {
it("should return user and session data", () => {
const mockUser: AuthUser = {