मैं प्रमाणीकरण के लिए IdentityServer4 के साथ अपने माइक्रोसर्विसेज के लिए एपीआई गेटवे के रूप में ओसेलोट का उपयोग कर रहा हूं। ऑसीलॉट कॉन्फिग फाइल में मैंने "ऑथेंटिकेशनऑक्शंस" जोड़ा और एपी की को सेट किया। में स्टार्टअप मैं पहचान सर्वर जोड़ें। पहचान सर्वर में मैं हेडर से मूल्य का उपयोग गतिशील रूप से कनेक्शन स्ट्रिंग बनाने के लिए करता हूं। जब मैं टोकन प्राप्त करने के लिए अनुरोध भेजता हूं, हेडर पहचान सेवा में पहुंच योग्य होते हैं। लेकिन जब मैं टोकन के साथ अगला अनुरोध भेजता हूं तो मूल हेडर उपलब्ध नहीं होते हैं। पहचान सेवा में केवल "होस्ट" हेडर दिखाई दे सकता है।
क्या पहचान सर्वर के अनुरोध को रूट करते समय मूल हेडर रखने का कोई तरीका है?
Startup.cs (पहचान सर्वर जोड़ें)
services
.AddAuthentication()
.AddIdentityServerAuthentication("APIParts", options =>
{
options.Authority = "http://localhost:60168";
options.RequireHttpsMetadata = false;
options.ApiName = "Parts";
options.SupportedTokens = SupportedTokens.Both;
});
ocelot.json
ReRoutes": [
{
"DownstreamPathTemplate": "/connect/token",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 60168
}
],
"UpstreamPathTemplate": "/token",
"UpstreamHttpMethod": [ "Post" ]
},
{
"DownstreamPathTemplate": "/api/Parts/Inventory",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 65241
}
],
"UpstreamPathTemplate": "/api/Parts/Inventory",
"AuthenticationOptions": {
"AuthenticationProviderKey": "APIParts",
"AllowedScopes": []
}
}]