Skip to content

Commit

Permalink
Merge pull request #5 from nordeck/add-helmchart
Browse files Browse the repository at this point in the history
BMI-383 add Chart
  • Loading branch information
emrahcom authored Dec 8, 2023
2 parents e2301b1 + 88a8fe5 commit d1a3939
Show file tree
Hide file tree
Showing 17 changed files with 1,446 additions and 0 deletions.
22 changes: 22 additions & 0 deletions charts/jitsi-keycloak-adapter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
annotations:
category: "Networking"
licenses: "Apache-2.0"
apiVersion: "v2"
dependencies:
- name: "common"
repository: "https://charts.bitnami.com/bitnami"
version: "^2.x.x"
- name: "jitsi-meet"
repository: "https://jitsi-contrib.github.io/jitsi-helm/"
version: "1.3.7"
alias: "jitsi"
description: "Deploy Jitsi with additional configuration."
home: "https://nordeck.net"
keywords:
- "jitsi"
- "networking"
name: "jitsi-keycloak-adapter"
type: "application"
version: "1.7.1"
...
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// -----------------------------------------------------------------------------
// This function creates the context inside JWT's payload. It gets userInfo
// (which comes from Keycloak) as parameter.
//
// Update the codes according to your requirements. Welcome to TypeScript :)
// -----------------------------------------------------------------------------

export function createContext(userInfo: Record<string, unknown>) {
const context = {
user: {
id: userInfo.sub,
name: userInfo.name || userInfo.preferred_username || "",
email: userInfo.email || "",
lobby_bypass: true,
},
};

return context;
}
146 changes: 146 additions & 0 deletions charts/jitsi-keycloak-adapter/files/web/oidc/body.oidc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<script>
let failedAttempt = 0;

function base32decode(s) {
const a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
const pad = "=";
const len = s.length;
const apad = a + pad;
let v, x, r=0, bits=0, c, o="";

s = s.toUpperCase();

for(i=0; i<len; i+=1) {
v = apad.indexOf(s.charAt(i));
if (v>=0 && v<32) {
x = (x << 5) | v;
bits += 5;
if (bits >= 8) {
c = (x >> (bits - 8)) & 0xff;
o = o + String.fromCharCode(c);
bits -= 8;
}
}
}

// remaining bits are < 8
if (bits>0) {
c = ((x << (8 - bits)) & 0xff) >> (8 - bits);
// Dont append a null terminator.
if (c!==0) {
o = o + String.fromCharCode(c);
}
}

return o;
}

function oidcRedirect() {
const qs = new URLSearchParams(window.location.search.substring(1));
qs.delete('oidc');

const path = encodeURIComponent(window.location.pathname);
const search = encodeURIComponent(qs.toString());
const hash = encodeURIComponent(window.location.hash.substring(1));

window.location = `/oidc/auth?path=${path}&search=${search}&hash=${hash}`;

try {
// remove react from DOM to prevent UI distortion
document.all.react.remove();
} catch {
// do nothing
}
}

function interceptLoginRequest() {
try {
// if conference is already started, dont wait for an auth request
if (APP.conference.isJoined()) return;

// check if login or IamHost button is created in DOM
const _button = document.getElementById("modal-dialog-ok-button");
if (!_button) throw("button is not created yet");

let labelKey;
try {
labelKey = Object.values(_button)[0].return.memoizedProps.labelKey;
} catch {
// do nothing
}

if (labelKey === "dialog.login") {
// if this is a login screen, redirect to OIDC login page
oidcRedirect();
} else if (labelKey === "dialog.IamHost") {
// if this is an IamHost screen, redirect to OIDC login page when clicked
_button.onclick = oidcRedirect
}
} catch(e) {
failedAttempt += 1;

if (failedAttempt < 180) {
setTimeout(function() {interceptLoginRequest();}, 1000);
}
}
}

// This function customizes Jitsi UI if the room is created by Element Jitsi
// Widget. It senses the room created by Element by checking its name. The room
// created by Element has a special name format:
//
// base32decode(room_name) should match RegExp("^(!.*:.*[.][a-z]*)$")
// or
// room_name should match RegExp("^(Jitsi[A-Z][a-z]{23})$")
function updateUIforElement() {
try {
if (!APP.conference.isJoined()) throw new Error("not joined yet");

try {
const roomName = APP.store.getState()["features/base/conference"].room;
const decoded = base32decode(roomName);
const reg1 = new RegExp("^(!.*:.*[.][a-z]*)$");
const reg2 = new RegExp("^(Jitsi[A-Z][a-z]{23})$");
if (!reg1.test(decoded) && !reg2.test(roomName)) {
throw new Error("not a Matrix room");
}

APP.store.getState()["features/base/config"].toolbarButtons = [
"camera",
"closedcaptions",
"desktop",
"download",
"feedback",
"filmstrip",
"fullscreen",
"hangup",
"help",
"livestreaming",
"microphone",
"mute-everyone",
"mute-video-everyone",
"participants-pane",
"profile",
"raisehand",
"security",
"select-background",
"settings",
"shareaudio",
"shortcuts",
"stats",
"tileview",
"toggle-camera",
"videoquality",
];
} catch {
// do nothing
}

} catch {
setTimeout(updateUIforElement, 1000);
}
}

interceptLoginRequest();
updateUIforElement();
</script>
Loading

0 comments on commit d1a3939

Please sign in to comment.