This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http.server | |
import socketserver | |
import threading | |
import urllib.parse | |
def wait_for_oauth_callback(port: int = 9090) -> str: | |
code: str | None = None | |
class CallbackHandler(http.server.SimpleHTTPRequestHandler): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Subscriber struct { | |
send chan string | |
} | |
type Hub struct { | |
clients map[*Subscriber]bool | |
broadcast chan string | |
register chan *Subscriber | |
unregister chan *Subscriber | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IdentityModel.Tokens.Jwt; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.Caching.Memory; | |
namespace JwtUtils | |
{ | |
public interface IJwtCache | |
{ | |
void Set(string key, JwtSecurityToken token); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import httpx | |
import subprocess | |
import logging | |
import typer | |
from pathlib import Path | |
logging.basicConfig( | |
level=logging.DEBUG, | |
format="%(levelname)s %(asctime)s: %(message)s", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.AddSwaggerGen(c => | |
{ | |
// ... | |
c.AddSecurityDefinition("bearer", new OpenApiSecurityScheme | |
{ | |
Description = | |
"Authenticate with an existing JWT token. **Prefix the token with `Bearer`, i.e. `Bearer eyJ...`**", | |
In = ParameterLocation.Header, | |
Name = HeaderNames.Authorization, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dataclasses | |
import functools | |
import io | |
import pathlib | |
from datetime import timedelta, datetime | |
from io import FileIO | |
from typing import Callable | |
import httpx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel.DataAnnotations; | |
using System.Linq; | |
using System.Net.Http; | |
using System.Net.Mime; | |
using System.Text.Json; | |
using System.Text.Json.Serialization; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Mvc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class LoginType | |
{ | |
public string Name { get; set; } | |
public static ICollection<LoginType> All { get; set; } = new List<LoginType>(); | |
public static LoginType Internal = new LoginType(nameof(Internal)); | |
public static LoginType Customer = new LoginType(nameof(Customer)); | |
public static LoginType Impersonation = new LoginType(nameof(Impersonation)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>net5.0</TargetFramework> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.4" /> | |
<PackageReference Include="NewId" Version="3.0.3" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class HostBuilderExtensions | |
{ | |
public static IHostBuilder UseStartup<TStartup>(this IHostBuilder hostBuilder) | |
where TStartup : class => | |
hostBuilder.ConfigureServices((ctx, sc) => | |
{ | |
var startupType = typeof(TStartup); | |
var startupArgs = startupType | |
.GetConstructors().First() | |
.GetParameters() |
NewerOlder