Skip to content

Instantly share code, notes, and snippets.

@vincentchalamon
vincentchalamon / .env
Last active June 1, 2023 14:25
API Platform Keycloak Swagger
OIDC_SERVER_URL=https://localhost/oidc/realms/demo
OIDC_SWAGGER_CLIENT_ID=api-platform-swagger
@vincentchalamon
vincentchalamon / security.yaml
Created March 4, 2022 15:46
API Platform Keycloak Security
# config/packages/security.yaml
security:
enable_authenticator_manager: true
providers:
app_user_provider:
entity:
class: App\Entity\User
property: email
firewalls:
main:
@vincentchalamon
vincentchalamon / hwi_oauth.yaml
Created March 4, 2022 15:45
API Platform Keycloak hwi/oauth-bundle Configuration
# config/packages/hwi_oauth.yaml
hwi_oauth:
resource_owners:
keycloak:
type: keycloak
base_url: <keycloak_url> # should look like https://www.example.com/auth
realm: <realm_name>
client_id: <client_id>
client_secret: <client_secret>
@vincentchalamon
vincentchalamon / docker-compose.yaml
Last active August 11, 2023 10:30
API Platform Keycloak Docker Compose
# docker-compose.yaml
version: "3.8"
services:
keycloak-database:
image: postgres:15-alpine
volumes:
- keycloak_db_data:/var/lib/postgresql/data:rw
environment:
POSTGRES_DB: keycloak
@vincentchalamon
vincentchalamon / fixInterfaceScope.sh
Last active June 28, 2022 08:39
Fix SNX interface scope
fixInterfaceScope() {
interface=tunsnx
data=($(ip -o address show "$interface" | awk -F ' +' '{print $4 " " $6 " " $8}'))
LOCAL_ADDRESS_INDEX=1
PEER_ADDRESS_INDEX=2
SCOPE_INDEX=3
if [ "${data[$SCOPE_INDEX]}" = "global" ]
then
echo "Interface ${interface} is already set to global scope. Skip!"
return
import NextAuth from "next-auth";
import Providers from "next-auth/providers";
import {fetch} from "utils/dataAccess";
const options = {
providers: [
Providers.Credentials({
name: 'Credentials',
authorize: async (credentials) => {
const response = await fetch("/login_check", {
@vincentchalamon
vincentchalamon / reserved
Last active August 16, 2020 09:41
MySQL reserved words detector
#!/usr/bin/env php
<?php
/**
* Create the bin/reserved file in your project, and copy/paste this as content
* Add execution permissions: chmod +x bin/reserved
*/
set_time_limit(0);
@vincentchalamon
vincentchalamon / cypress.js
Created December 9, 2019 14:28
Cypress.io: parse iframe content
Cypress.Commands.add('iframe', {
prevSubject: 'element',
}, $iframe => {
const contentWindow = $iframe.prop('contentWindow');
return new Promise(resolve => {
if (contentWindow && contentWindow.document.readyState === 'complete') {
resolve(contentWindow);
} else {
$iframe.on('load', () => {
@vincentchalamon
vincentchalamon / cypress.js
Created December 9, 2019 14:27
Cypress.io: keep session between tests
Cypress.Cookies.defaults({
whitelist: 'PHPSESSID',
});
@vincentchalamon
vincentchalamon / cypress.js
Created December 9, 2019 14:26
Replace `fetch` requests to `xhr` in Cypress configuration
before(() => {
Cypress.log({});
cy.request('https://unpkg.com/unfetch@4.1.0/dist/unfetch.umd.js', {log: false}).as('unfetch').then(unfetch => {
Cypress.on('window:before:load', win => {
delete win.fetch;
win.eval(unfetch);
win.fetch = win.unfetch;
});
});