ASP.NET Core JWT Bearer: ṣeto proxy backchannel metadata
Lo BackchannelHttpHandler ṣaaju ki gbigba to bẹrẹ, ayafi ti alabara pipe tabi oludari iṣeto aṣa ba ti ni irin-ajo yẹn tẹlẹ.
API le gba bearer token ki o si kuna ninu gbigba metadata ati bọtini ibuwọlu server. Ṣeto ero JWT bearer yẹn lẹhin iforukọsilẹ ti o wa tẹlẹ ati ṣaaju awọn ibeere:
using System.Net;
using Microsoft.AspNetCore.Authentication.JwtBearer;
builder.Services.Configure<JwtBearerOptions>(
JwtBearerDefaults.AuthenticationScheme, options =>
{
options.BackchannelHttpHandler = new HttpClientHandler
{
UseProxy = true,
Proxy = new WebProxy("http://proxy.example:8080")
};
});Ba orukọ ti o forukọsilẹ mu; ti o ba yatọ si Bearer aiyipada, lo orukọ gidi rẹ. Pa Authority, Audience ati awọn paramita token ti o wa mọ. Ipin ipari metadata ati bọtini ibuwọlu ti gbogbo eniyan le lo oludije lati akojọ proxy HTTP fun URL WebProxy ti ko ni akọọlẹ yii nigbati a gba iwọle nipasẹ proxy gbangba laaye.
Ninu iṣeto boṣewa, post-configuration ṣẹda backchannel lati handler yii. Ti Backchannel pipe tabi ConfigurationManager aṣa ba ti pese olugba naa tẹlẹ, ṣeto ohun yẹn dipo. Ohun-ini handler ko bori awọn mejeeji.
Ṣeto eyikeyi akọọlẹ proxy lori WebProxy ṣaaju lilo, kii ṣe nipa yiyipada Proxy inu SendAsync. Pa issuer, audience, ibuwọlu, igbesi aye ati awọn oludaniloju afikun mọ. Wiwọle OIDC ati gbigba token lọtọ tọju awọn ọna HTTP tiwọn.