Skip to content

Instantly share code, notes, and snippets.

View ghstahl's full-sized avatar
💭
coding always coding

Herb Stahl ghstahl

💭
coding always coding
  • Santa Monica, CA
View GitHub Profile
{
"issuer": "https://accounts.google.com",
"authorization_endpoint": "https://localhost:6001/connect/authorize",
"token_endpoint": "https://localhost:6001/connect/token",
"userinfo_endpoint": "https://openidconnect.googleapis.com/v1/userinfo",
"revocation_endpoint": "https://oauth2.googleapis.com/revoke",
"jwks_uri": "https://www.googleapis.com/oauth2/v3/certs",
"response_types_supported": ["code", "token", "id_token", "code token", "code id_token", "token id_token", "code token id_token", "none"],
"subject_types_supported": ["public"],
"id_token_signing_alg_values_supported": ["RS256"],
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IdentityModel;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;

Keybase proof

I hereby claim:

  • I am ghstahl on github.
  • I am ghstahl (https://keybase.io/ghstahl) on keybase.
  • I have a public key ASB9Dis5iMFoUSYXBkRAEKIWVPL--pjwojBGE5WE-rzMbwo

To claim this, I am signing this object:

using Azure.Security.KeyVault.Keys;
using Azure.Security.KeyVault.Secrets;
using System;
namespace Common
{
public class AzureKeyVaultClients : IAzureKeyVaultClients
{
private AzureKeyVaultTokenCredential _azureKeyVaultTokenCredential;
@ghstahl
ghstahl / GraphQLStarWarsExtension
Created December 23, 2016 19:32
Autofac registration for the GraphQL StarWars types
// https://github.com/graphql-dotnet/graphql-dotnet
public static class GraphQLStarWarsExtension
{
public static void RegisterGraphQLTypes(this ContainerBuilder builder)
{
builder.RegisterInstance(new DocumentExecuter()).As<IDocumentExecuter>();
builder.RegisterInstance(new DocumentWriter()).As<IDocumentWriter>();
builder.RegisterInstance(new StarWarsData()).As<StarWarsData>();
public async Task<IActionResult> OnGetCallbackAsync(
string returnUrl = null,
string remoteError = null)
{
returnUrl = returnUrl ?? Url.Content("~/");
if (remoteError != null)
{
ErrorMessage = $"Error from external provider: {remoteError}";
return RedirectToPage("./Login", new {ReturnUrl = returnUrl});
}
var sessionKey = GuidN;
var identity = await base.GenerateClaimsAsync(user);
identity.AddClaim(new Claim(".sessionKey", sessionKey));
HttpContext.Session.SetString(sessionKey, sessionKey);
app.UseSession();
app.UseAuthentication();
app.UseAuthorization();
app.UseMiddleware<AuthSessionValidationMiddleware>();
@ghstahl
ghstahl / medium-a6abd001-f84f-4d6e-8d9b-a45f12b7e09e.cs
Last active October 12, 2020 17:04
Keeping Authentication and Session in sync in asp.net core 3.x - Startup.cs identity
services.AddIdentity<IdentityUser,IdentityRole>(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
// services.AddDefaultIdentity must be adding its own fake
// Switched to services.AddIdentity<IdentityUser,IdentityRole>, and now I have to add it.
services.AddScoped<IEmailSender, FakeEmailSender>();
services.AddScoped<IUserClaimsPrincipalFactory<IdentityUser>, SeedSessionClaimsPrincipalFactory>();
public interface ICustomTokenRequestManager
{
void AddTokenRequestFunction(string key, Func<ManagedToken, IServiceProvider,IOAuth2CredentialManager, CancellationToken, Task<ManagedToken>> func);
Func<ManagedToken, IServiceProvider,IOAuth2CredentialManager, CancellationToken, Task<ManagedToken>> GetTokenRequestFunc(string key);
}