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

This commit is contained in:
John Livingston 2024-04-18 10:58:08 +02:00
parent c3d7102d4a
commit 51c8a573c7
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
4 changed files with 40 additions and 4 deletions

View File

@ -168,6 +168,16 @@ async function initConverse (
if (tryOIDC && !isAuthenticated) {
params.livechat_external_auth_oidc_button_label = initConverseParams.externalAuthOIDC?.buttonLabel
params.livechat_external_auth_oidc_url = initConverseParams.externalAuthOIDC?.url
switch (chatIncludeMode) {
case 'peertube-video':
params.livechat_external_auth_reconnect_mode = 'button-close-open'
break
case 'peertube-fullpage':
case 'chat-only':
default:
params.livechat_external_auth_reconnect_mode = 'reload'
}
}
if (chatIncludeMode === 'peertube-video') {

View File

@ -1,4 +1,4 @@
import { api } from '@converse/headless/core'
import { _converse, api } from '@converse/headless/core'
import { __ } from 'i18n'
import { html } from 'lit'
@ -50,8 +50,32 @@ export const tplExternalLoginModal = (el, o) => {
// Storing the token in sessionStorage.
window.sessionStorage.setItem('peertube-plugin-livechat-oidc-token', data.token)
// FIXME: do better.
window.location.reload()
const reconnectMode = api.settings.get('livechat_external_auth_reconnect_mode')
if (reconnectMode === 'button-close-open') {
// Here, we click on the close button, then on the open button.
// FIXME: there is maybe a better way to do this.
try {
// But first, close the modal.
document.getElementsByClassName('livechat-external-login-modal')[0]
.closest('.modal-dialog')
.querySelector('button.close')
.click()
// As soon as disconnected, re-open:
_converse.api.listen.once('disconnected', () => {
document.getElementsByClassName('peertube-plugin-livechat-button-open')[0].click()
})
// And we close!
document.getElementsByClassName('peertube-plugin-livechat-button-close')[0].click()
} catch (err) {
// fallback... reloading window :/
console.error(err)
window.location.reload()
}
} else { // reload and other use cases...
window.location.reload()
}
}
return false

View File

@ -38,6 +38,7 @@ export const livechatSpecificsPlugin = {
'hide_muc_participants',
'livechat_enable_viewer_mode',
'livechat_external_auth_oidc_button_label', 'livechat_external_auth_oidc_url',
'livechat_external_auth_reconnect_mode',
'livechat_mini_muc_head'
]) {
_converse.api.settings.set(k, params[k])

View File

@ -10,7 +10,8 @@ export const livechatViewerModePlugin = {
livechat_peertube_video_original_url: undefined,
livechat_peertube_video_uuid: undefined,
livechat_external_auth_oidc_button_label: undefined,
livechat_external_auth_oidc_url: undefined
livechat_external_auth_oidc_url: undefined,
livechat_external_auth_reconnect_mode: undefined
})
const originalGetDefaultMUCNickname = _converse.getDefaultMUCNickname