Possibility to configure an OpenID Connect provider on the instance level WIP (#128).

This commit is contained in:
John Livingston
2024-04-15 18:29:09 +02:00
parent c1e877cb44
commit 514cc1d159
14 changed files with 388 additions and 12 deletions

View File

@ -0,0 +1,39 @@
import type { RegisterServerOptions } from '@peertube/peertube-types'
import { newResult, TestResult } from './utils'
import { ExternalAuthOIDC } from '../external-auth/oidc'
export async function diagExternalAuthCustomOIDC (test: string, _options: RegisterServerOptions): Promise<TestResult> {
const result = newResult(test)
result.label = 'Test External Auth Custom OIDC'
result.next = 'everything-ok'
try {
const oidc = ExternalAuthOIDC.singleton()
if (oidc.isDisabledBySettings()) {
result.ok = true
result.messages.push('Feature disabled in plugins settings.')
return result
}
const errors = await oidc.check()
if (errors.length) {
result.messages.push({
level: 'error',
message: 'The ExternalAuthOIDC singleton got some errors:'
})
result.messages.push(...errors)
return result
}
} catch (err) {
result.messages.push({
level: 'error',
message: 'Error while retrieving the ExternalAuthOIDC singleton:' + (err as string)
})
return result
}
result.ok = true
result.messages.push('Configuration OK.')
return result
}

View File

@ -4,6 +4,7 @@ import { TestResult, newResult } from './utils'
import { diagDebug } from './debug'
import { diagProsody } from './prosody'
import { diagVideo } from './video'
import { diagExternalAuthCustomOIDC } from './external-auth-custom-oidc'
import { helpUrl } from '../../../shared/lib/help'
export async function diag (test: string, options: RegisterServerOptions): Promise<TestResult> {
@ -17,6 +18,8 @@ export async function diag (test: string, options: RegisterServerOptions): Promi
result = await diagVideo(test, options)
} else if (test === 'prosody') {
result = await diagProsody(test, options)
} else if (test === 'external-auth-custom-oidc') {
result = await diagExternalAuthCustomOIDC(test, options)
} else if (test === 'everything-ok') {
result = newResult(test)
result.label = 'Everything seems fine'

View File

@ -236,6 +236,6 @@ export async function diagProsody (test: string, options: RegisterServerOptions)
}
result.ok = true
result.next = 'everything-ok'
result.next = 'external-auth-custom-oidc'
return result
}

View File

@ -1,4 +1,4 @@
type nextValue = 'backend' | 'debug' | 'webchat-video' | 'prosody' | 'everything-ok'
type nextValue = 'backend' | 'debug' | 'webchat-video' | 'prosody' | 'external-auth-custom-oidc' | 'everything-ok'
interface MessageWithLevel {
level: 'info' | 'warning' | 'error'