Skip to content

Instantly share code, notes, and snippets.

View mrnkr's full-sized avatar
🏠
Working from home

Alvaro Nicoli mrnkr

🏠
Working from home
View GitHub Profile
@mrnkr
mrnkr / TokenService.cs
Created April 8, 2020 02:56
This is how I create jwt tokens in C#
using Microsoft.Extensions.Configuration;
using Microsoft.IdentityModel.Tokens;
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;
namespace TwoDrive.Core
{
public class TokenService
@mrnkr
mrnkr / Startup.cs
Created April 8, 2020 03:05
This is how to configure JwtBearer authentication in C# to use a firebase id token
services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = "https://securetoken.google.com/firebase-project";
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidIssuer = "https://securetoken.google.com/firebase-project",
ValidateAudience = true,
@mrnkr
mrnkr / ExtractUserExtension.cs
Last active April 9, 2020 00:03
This is how I retrieve the user from my request without tears
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace TwoDrive.Api
{
public static class ExtractUserExtension
{
protected static string GetLoggedUserId(this ControllerBase ctrl)
@mrnkr
mrnkr / calculateValueWithJsonLogic.json
Created November 9, 2020 12:29
Compute value form.io - this calculation will be performed on build time and the result will be stored in the db, not the logic to compute it
{
"key": "customConditional",
"type": "hidden",
"input": false,
"clearOnHide": false,
"calculateValue": {
"==": [
{ "==": [{ "var": "component.conditional.show" }, "true"] },
{ "==": [{ "var": "data[component.conditional.when].value" }, { "var": "component.conditional.eq" }] },
]
@mrnkr
mrnkr / .zshrc
Created November 30, 2021 18:42
My .zshrc
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH