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

This commit is contained in:
John Livingston
2024-04-17 16:35:26 +02:00
parent 8574ab581d
commit 3a5f27e751
7 changed files with 230 additions and 1 deletions

View File

@ -140,6 +140,7 @@ class ProsodyConfigContent {
global: ProsodyConfigGlobal
authenticated?: ProsodyConfigVirtualHost
anon?: ProsodyConfigVirtualHost
external?: ProsodyConfigVirtualHost
muc: ProsodyConfigComponent
bot?: ProsodyConfigVirtualHost
externalComponents: ProsodyConfigComponent[] = []
@ -222,6 +223,19 @@ class ProsodyConfigContent {
}
}
/**
* Activates the virtual host for external account authentication (OpenID Connect, ...)
*/
useExternal (apikey: string): void {
this.external = new ProsodyConfigVirtualHost('external.' + this.prosodyDomain)
this.external.set('modules_enabled', [
'ping',
'http',
'http_peertubelivechat_manage_users'
])
this.external.set('peertubelivechat_manage_users_apikey', apikey)
}
useHttpAuthentication (url: string): void {
this.authenticated = new ProsodyConfigVirtualHost(this.prosodyDomain)
@ -304,6 +318,17 @@ class ProsodyConfigContent {
this.authenticated.set('http_host', prosodyDomain)
this.authenticated.set('http_external_url', 'http://' + prosodyDomain)
}
if (this.external) {
this.external.set('allow_anonymous_s2s', false)
this.external.add('modules_enabled', 'http')
this.external.add('modules_enabled', 'bosh')
if (useWS) {
this.external.add('modules_enabled', 'websocket')
}
this.external.set('http_host', prosodyDomain)
this.external.set('http_external_url', 'http://' + prosodyDomain)
}
}
useC2S (c2sPort: string): void {
@ -501,6 +526,10 @@ class ProsodyConfigContent {
content += this.bot.write()
content += '\n\n'
}
if (this.external) {
content += this.external.write()
content += '\n\n'
}
content += this.muc.write()
content += '\n\n'
for (const externalComponent of this.externalComponents) {