Skip to content

Instantly share code, notes, and snippets.

@xximjasonxx
Created March 10, 2021 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xximjasonxx/097ce5eb39318d67f4226040b0920754 to your computer and use it in GitHub Desktop.
Save xximjasonxx/097ce5eb39318d67f4226040b0920754 to your computer and use it in GitHub Desktop.
var keyVaultService = new KeyVaultService(new GetCredentialService(Configuration), Configuration);
var tokenSecurityValidator = new JwtSecurityTokenValidator(Configuration, keyVaultService);
services.AddTransient<CryptoService>()
.AddTransient<JwtTokenService>()
.AddSingleton<TwitchAuthService>()
.AddSingleton(p => keyVaultService)
.AddTransient(p => tokenSecurityValidator)
.AddSingleton<GetCredentialService>()
.AddTransient<TwitchApiService>()
.AddTransient<GetTokensFromHttpRequestService>()
.AddTransient<ProcessApiResultFilter>();
// add auth middleware
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.RequireHttpsMetadata = false;
options.SecurityTokenValidators.Add(tokenSecurityValidator);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment