Skip to content

Instantly share code, notes, and snippets.

Avatar

Mathieu ANCELIN mathieuancelin

View GitHub Profile
View jwt.sh
function jwt_decode() {
jq -R 'split(".") | .[0] | @base64d | fromjson' <<< "$1"
jq -R 'split(".") | .[1] | @base64d | fromjson | if .iat then (.iat_str = (.iat|gmtime|strftime("%Y-%m-%dT%H:%M:%S %Z"))) else . end | if .exp then (.exp_str = (.exp|gmtime|strftime("%Y-%m-%dT%H:%M:%S %Z"))) else . end | if .nbf then (.nbf_str = (.nbf|gmtime|strftime("%Y-%m-%dT%H:%M:%S %Z"))) else . end' <<< "$1"
}
View otoroshi (2).json
{
"clientId": "otoroshi",
"name": "otoroshi",
"description": "otoroshi",
"rootUrl": "http://localhost:8080",
"adminUrl": "http://localhost:8080/*",
"surrogateAuthRequired": false,
"enabled": true,
"alwaysDisplayInConsole": false,
"clientAuthenticatorType": "client-x509",
View defer.scala
package otoroshi.plugins.defer
import akka.http.scaladsl.util.FastFuture
import akka.stream.Materializer
import env.Env
import org.joda.time.DateTime
import otoroshi.script._
import play.api.libs.json._
import play.api.mvc.Result
View otoroshi-redis.md

Otoroshi cluster demos

assuming your local ip address is 192.168.86.194

Getting otoroshi

curl -L -o otoroshi.jar 'https://dl.bintray.com/maif/binaries/otoroshi.jar/1.4.6/otoroshi.jar'
# or
curl -L -o otoroshi.jar 'https://dl.bintray.com/maif/binaries/otoroshi.jar/snapshot/otoroshi.jar'
View e2ee.js
/*
"dependencies": {
"bcrypt": "3.0.3",
"node-jsencrypt": "1.0.0"
}
*/
const bcrypt = require('bcrypt');
const JSEncrypt = require('node-jsencrypt');
const _crypto = require('crypto');
View yubikey.sh
#!/bin/bash
set -e
outfile=
passfile=
pin=
encKey=01
action=encrypt
View overscan.sh
xrandr --output DP-1 --set underscan on
xrandr --output DP-1 --set "underscan hborder" 31 --set "underscan vborder" 42
@mathieuancelin
mathieuancelin / index.js
Created Apr 26, 2018
Copy Otoroshi apikeys from one group to another
View index.js
const fetch = require('node-fetch');
const base64 = require('base-64');
const argv = require('minimist')(process.argv.slice(2));
const OTOROSHI_URL = argv['otoroshi-url'] || 'http://otoroshi-api.foo.bar'
const APIKEY_ID = argv['otoroshi-apikey-id'] || 'admin-api-apikey-id'
const APIKEY_SECRET = argv['otoroshi-apikey-secret'] || 'admin-api-apikey-secret'
const SERVICE_FROM = argv['service-from'] || '--';
const SERVICE_TO = argv['service-to'] || '--';
View server.js
const http = require('http');
const url = require('url');
const faker = require('faker');
const bytes = require('bytes');
const _ = require('lodash');
const port = process.env.PORT || process.argv[2] || 8080;
const cache = {};
View app.scala
package app
import cats.Applicative
import cats.effect._
import cats.implicits._
import fs2.StreamApp.ExitCode
import fs2.{Stream, StreamApp}
import io.circe._
import io.circe.generic.semiauto._
import org.http4s.circe._