Skip to content

Instantly share code, notes, and snippets.

View maitrungduc1410's full-sized avatar
💪
Keep chasing your dreams!

Duc Trung Mai maitrungduc1410

💪
Keep chasing your dreams!
View GitHub Profile
@maitrungduc1410
maitrungduc1410 / Dockerfile
Created October 22, 2023 03:38
Docker Centos Nginx JWT
FROM quay.io/sclorg/nginx-120-c8s as base
FROM base as builder
USER root
ARG JWT_MODULE_PATH=/usr/local/lib/ngx-http-auth-jwt-module
ARG LIBJWT_VERSION=1.13.1
ARG NGINX_VERSION=1.20.0
@maitrungduc1410
maitrungduc1410 / middleware.ts
Created July 8, 2023 03:40
Sync session between Next Auth and Keycloak
import { withAuth } from "next-auth/middleware";
export default withAuth(
{
pages: {
signIn: "/auth/signin",
},
callbacks: {
authorized: async ({ token }) => {
if (!(token as any)?.id_token) return false;
@maitrungduc1410
maitrungduc1410 / _silent-check-sso.html
Created January 4, 2023 04:13
Openedx Keycloak federated login (SSO)
<html>
<body>
<script>
parent.postMessage(location.href, location.origin)
</script>
</body>
</html>
@maitrungduc1410
maitrungduc1410 / _silent-check-sso.html
Last active January 4, 2023 04:18
Openedx Keycloak Federated Logout (Single sign out)
<html>
<body>
<script>
parent.postMessage(location.href, location.origin)
</script>
</body>
</html>
@maitrungduc1410
maitrungduc1410 / index.js
Last active December 27, 2022 03:25
Import users from OpenEdx to Keycloak with NodeJS
import KcAdminClient from "@keycloak/keycloak-admin-client";
const kcAdminClient = new KcAdminClient({
baseUrl: "http://localhost:8080",
realmName: "myrealm",
});
const credentials = {
grantType: "password",
username: "superuser",
@maitrungduc1410
maitrungduc1410 / angular.json
Last active September 25, 2022 03:15
Angular (NGX) Intro.js
{
"projects": {
"ngx-introjs": {
"architect": {
"build": {
"options": {
"styles": [
"node_modules/intro.js/introjs.css"
],
"scripts": [
@maitrungduc1410
maitrungduc1410 / client_3.py
Created December 9, 2020 02:26
Demo streaming audio data to Api-gateway
import argparse
from ws4py.client.threadedclient import WebSocketClient
import time
import threading
import sys
import urllib.parse
import queue
import json
import time
import os
@maitrungduc1410
maitrungduc1410 / package.json
Last active March 2, 2023 23:23
Update Npm and SonarQube on Git commit (using Husky)
{
"name": "demo-project",
"version": "0.0.3",
"husky": {
"hooks": {
"pre-commit": "npm --no-git-tag-version version patch && sh updateSonarProps.sh && git add ."
}
}
}
@maitrungduc1410
maitrungduc1410 / docker-compose.yml
Created November 4, 2020 03:00
Docker PHP Nginx without mouting source code to Nginx
version: '3.4'
services:
app:
image: php:7.2-fpm-alpine
restart: unless-stopped
volumes:
- ./:/var/www/html
- ./www.conf:/usr/local/etc/php-fpm.d/www.conf
webserver:
@maitrungduc1410
maitrungduc1410 / client_2.py
Last active August 6, 2021 16:28
Kaldi Gstreamer Client for decoding from file and microphone (Python 2 and 3)
import argparse
from ws4py.client.threadedclient import WebSocketClient
import time
import threading
import sys
import urllib
import Queue
import json
import os
import datetime