Skip to content

Instantly share code, notes, and snippets.

View beleidy's full-sized avatar

Amr Elbeleidy beleidy

  • Lisbon, Portugal
View GitHub Profile
{
"ignition": {
"config": {
"replace": {
"source": null,
"verification": {}
}
},
"security": {
"tls": {}
@beleidy
beleidy / kitty.conf
Created March 16, 2020 16:48
Configuration file for kitty
scrollback_lines 10000
#Fonts
font_family Cascadia Code Regular
bold_font auto
italic_font auto
bold_italic_font auto
font_size 12.5
@beleidy
beleidy / history.zsh
Created October 4, 2019 19:32
Zsh history settings -- taken from oh-my-zsh
## History wrapper
function omz_history {
local clear list
zparseopts -E c=clear l=list
if [[ -n "$clear" ]]; then
# if -c provided, clobber the history file
echo -n >| "$HISTFILE"
echo >&2 History file deleted. Reload the session to see its effects.
elif [[ -n "$list" ]]; then
@beleidy
beleidy / .zshrc
Last active March 16, 2020 16:41
Setting up zsh with Powerlevel9k and zsh-autosuggestions (some settings copied from oh-my-zsh files)
## Keybindings section
bindkey -e
bindkey '^[[7~' beginning-of-line # Home key
bindkey '^[[H' beginning-of-line # Home key
if [[ "${terminfo[khome]}" != "" ]]; then
bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
fi
bindkey '^[[8~' end-of-line # End key
bindkey '^[[F' end-of-line # End key
if [[ "${terminfo[kend]}" != "" ]]; then
jwt_payload = jwt.decode(jwt_id_token, public_key, algorithms=[jwt_alg], audience=audience)
from jwt.algorithms import RSAAlgorithm
jwt_key = [key for key in JWKS_KEYS if key['kid'] == jwt_kid][0]
public_key = RSAAlgorithm.from_jwk(json.dumps(jwt_key))
jwt_headers = jwt.get_unverified_header(jwt_id_token)
jwt_alg = jwt_headers['alg']
jwt_kid = jwt_headers['kid'] # kid is short for key id
if jwks_uri is not None:
response = requests.get(jwks_uri)
response_json = response.json()
keys = response_json.get("keys", None)
GOOGLE_DISCOVERY_URI = "https://accounts.google.com/.well-known/openid-configuration"
response = requests.get(GOOGLE_DISCOVERY_URI)
response_json = response.json()
# If for any reason we don't get the expected response
# using the get method is safer
jwks_uri = response_json.get("jwks_uri", None)
@beleidy
beleidy / medium-oauth2-jwt-1.py
Created February 9, 2019 13:23
Get ID JWT from Google OAuth2 credentials
flow = google_auth_oauthlib.flow.Flow.from_client_config(
CLIENT_SECRET, scopes=SCOPES)
flow.redirect_uri = url_for('oauth2_callback', _external=True)
authorization_response = request.url
# Replace with https to avoid InsecureTrasnportError
authorization_response = authorization_response.replace('http', 'https')
flow.fetch_token(authorization_response=authorization_response)