DecodeJWS नीति

आपको Apigee Edge दस्तावेज़ दिख रहा है.
अभी तक किसी भी व्यक्ति ने चेक इन नहीं किया है इस पेज पर जाएं Apigee X दस्तावेज़.
जानकारी

क्या

JWS पर हस्ताक्षर की पुष्टि किए बिना, JWS हेडर को डिकोड करता है. साथ ही, हर हेडर को फ़्लो वैरिएबल. यह नीति सबसे ज़्यादा तब काम आती है, जब VerifyJWS की नीति के साथ कॉन्सर्ट में इसका इस्तेमाल किया जाता है. जब JWS के हस्ताक्षर की पुष्टि करने से पहले, JWS के किसी हेडर की वैल्यू पता होनी चाहिए.

किसी JWS में पेलोड अटैच हो सकता है, जैसा कि वह फ़ॉर्म में बताया गया है:

header.payload.signature

इसके अलावा, JWS पेलोड को हटा सकता है, जिसे डिटैच किया गया पेलोड कहा जाता है और वह इस तरह से हो सकता है:

header..signature

DecodeJWS नीति दोनों फ़ॉर्मैट के साथ काम करती है, क्योंकि यह JWS के हेडर वाले हिस्से को ही डीकोड करती है. DecodeJWS नीति भी काम करती है. भले ही, JWS पर साइन करने के लिए इस्तेमाल किया गया एल्गोरिदम कुछ भी हो.

ज़्यादा जानकारी के लिए, JWS और JWT की नीतियों के बारे में खास जानकारी देखें साथ ही, JWS फ़ॉर्मैट की ख़ास जानकारी भी मिलेगी.

वीडियो

किसी JWT को डिकोड करने का तरीका जानने के लिए एक छोटा वीडियो देखें. हालांकि, यह वीडियो इनमें से कई सिद्धांत JWS के लिए एक जैसे होते हैं.

सैंपल: किसी JWS को डिकोड करना

नीचे दिखाई गई नीति, फ़्लो वैरिएबल var.JWS में मिलने वाले JWS को डिकोड करती है. यह वैरिएबल मौजूद होना चाहिए और उसमें एक व्यावहारिक (डिकोडेबल) JWS होना चाहिए. नीति, JWS को यहां से हासिल कर सकती है: का इस्तेमाल किया जा सकता है.

<DecodeJWS name="JWS-Decode-HS256">
    <DisplayName>JWS Verify HS256</DisplayName>
    <Source>var.JWS</Source>
</DecodeJWS>

JWS के हेडर वाले हिस्से में मौजूद हर हेडर के लिए, नीति इस नाम का एक फ़्लो वैरिएबल सेट करती है:

jws.policy-name.header.header-name

अगर JWS में पेलोड अटैच है, तो यह jws.policy-name.header.payload को सेट करता है फ़्लो वैरिएबल को पेलोड में ले जाता है. डिटैच किए गए पेलोड के लिए, payload खाली है. इस नीति में सेट किए गए वैरिएबल की पूरी सूची देखने के लिए, फ़्लो वैरिएबल देखें.

JWS डिकोड करने के लिए एलिमेंट रेफ़रंस

नीति के रेफ़रंस में, डिकोड करने वाली JWS नीति के एलिमेंट और एट्रिब्यूट के बारे में बताया गया है.

ऐसे एट्रिब्यूट जो टॉप-लेवल एलिमेंट पर लागू करें

<DecodeJWS name="JWS" continueOnError="false" enabled="true" async="false">

ये एट्रिब्यूट, नीति के सभी पैरंट एलिमेंट में एक जैसे होते हैं.

एट्रिब्यूट जानकारी डिफ़ॉल्ट मौजूदगी
नाम नीति का अंदरूनी नाम. नाम में इस्तेमाल किए जा सकने वाले वर्ण इन तक सीमित हैं: A-Z0-9._\-$ %. हालांकि, Edge मैनेजमेंट यूज़र इंटरफ़ेस (यूआई) की मदद से पाबंदियां, जैसे कि अक्षर और अंक के अलावा किसी और वर्ण को अपने-आप हटाना.

विकल्प के तौर पर, <displayname></displayname> एलिमेंट का इस्तेमाल करके मैनेजमेंट यूज़र इंटरफ़ेस (यूआई) के प्रॉक्सी एडिटर में, नीति को अलग और आम भाषा में लेबल करें नाम.

लागू नहीं ज़रूरी है
continueOnError किसी नीति के काम न करने पर, गड़बड़ी दिखाने के लिए false पर सेट करें. यह उम्मीद है व्यवहार की जानकारी देने वाला डेटा.

नीति के लागू होने के बाद भी फ़्लो को एक्ज़ीक्यूट करने के लिए, इसे true पर सेट करें विफल होता है.

गलत वैकल्पिक
चालू किया गया नीति को लागू करने के लिए, true पर सेट करें.

false को "बंद करें" पर सेट करें नीति के बारे में ज़्यादा जानें. नीति लागू नहीं की जाएगी भले ही वह किसी फ़्लो से जुड़ा हुआ हो.

सही वैकल्पिक
एक साथ काम नहीं करने वाली प्रोसेस यह एट्रिब्यूट अब काम नहीं करता. गलत बहिष्कृत

&lt;DisplayName&gt;

<DisplayName>Policy Display Name</DisplayName>

मैनेजमेंट यूज़र इंटरफ़ेस (यूआई) प्रॉक्सी एडिटर में नीति को लेबल करने के लिए, नाम एट्रिब्यूट के अलावा इस्तेमाल करें पर क्लिक करें.

डिफ़ॉल्ट अगर इस एलिमेंट को छोड़ा जाता है, तो नीति के नाम वाले एट्रिब्यूट की वैल्यू का इस्तेमाल किया जाता है.
मौजूदगी वैकल्पिक
स्ट्रीम किस तरह की है स्ट्रिंग

&lt;Source&gt;

<Source>JWS-variable</Source>

अगर यह मौजूद है, तो यह उस फ़्लो वैरिएबल के बारे में बताता है जिसमें नीति के मुताबिक, JWS को डिकोड करना.

डिफ़ॉल्ट request.header.authorization (अहम जानकारी के लिए ऊपर दिया गया नोट देखें डिफ़ॉल्ट के बारे में जानकारी).
मौजूदगी वैकल्पिक
स्ट्रीम किस तरह की है स्ट्रिंग
मान्य वैल्यू एज फ़्लो वैरिएबल का नाम

Flow variables

Upon success, the Verify JWS and Decode JWS policies set context variables according to this pattern:

jws.{policy_name}.{variable_name}

For example, if the policy name is verify-jws, then the policy will store the algorithm specified in the JWS to this context variable: jws.verify-jws.header.algorithm

Variable name Description
decoded.header.name The JSON-parsable value of a header in the payload. One variable is set for every header in the payload. While you can also use the header.name flow variables, this is the recommended variable to use to access a header.
header.algorithm The signing algorithm used on the JWS. For example, RS256, HS384, and so on. See (Algorithm) Header Parameter for more.
header.kid The Key ID, if added when the JWS was generated. See also "Using a JSON Web Key Set (JWKS)" at JWT and JWS policies overview to verify a JWS. See (Key ID) Header Parameter for more.
header.type The header type value. See (Type) Header Parameter for more.
header.name The value of the named header (standard or additional). One of these will be set for every additional header in the header portion of the JWS.
header-json The header in JSON format.
payload The JWS payload if the JWS has an attached payload. For a detached payload, this variable is empty.
valid In the case of VerifyJWS, this variable will be true when the signature is verified, and the current time is before the token expiry, and after the token notBefore value, if they are present. Otherwise false.

In the case of DecodeJWS, this variable is not set.

गड़बड़ी का रेफ़रंस

This section describes the fault codes and error messages that are returned and fault variables that are set by Edge when this policy triggers an error. This information is important to know if you are developing fault rules to handle faults. To learn more, see What you need to know about policy errors and Handling faults.

Runtime errors

These errors can occur when the policy executes.

Fault code HTTP status Occurs when
steps.jws.FailedToDecode 401 The policy was unable to decode the JWS. The JWS is possibly corrupted.
steps.jws.FailedToResolveVariable 401 Occurs when the flow variable specified in the <Source> element of the policy does not exist.
steps.jws.InvalidClaim 401 For a missing claim or claim mismatch, or a missing header or header mismatch.
steps.jws.InvalidJsonFormat 401 Invalid JSON found in the JWS header.
steps.jws.InvalidJws 401 This error occurs when the JWS signature verification fails.
steps.jws.InvalidPayload 401 The JWS payload is invalid.
steps.jws.InvalidSignature 401 <DetachedContent> is omitted and the JWS has a detached content payload.
steps.jws.MissingPayload 401 The JWS payload is missing.
steps.jws.NoAlgorithmFoundInHeader 401 Occurs when the JWS omits the algorithm header.
steps.jws.UnknownException 401 An unknown exception occurred.

Deployment errors

These errors can occur when you deploy a proxy containing this policy.

Error name Occurs when
InvalidAlgorithm The only valid values are: RS256, RS384, RS512, PS256, PS384, PS512, ES256, ES384, ES512, HS256, HS384, HS512.

EmptyElementForKeyConfiguration

FailedToResolveVariable

InvalidConfigurationForActionAndAlgorithmFamily

InvalidConfigurationForVerify

InvalidEmptyElement

InvalidFamiliesForAlgorithm

InvalidKeyConfiguration

InvalidNameForAdditionalClaim

InvalidNameForAdditionalHeader

InvalidPublicKeyId

InvalidPublicKeyValue

InvalidSecretInConfig

InvalidTypeForAdditionalClaim

InvalidTypeForAdditionalHeader

InvalidValueForElement

InvalidValueOfArrayAttribute

InvalidVariableNameForSecret

MissingConfigurationElement

MissingElementForKeyConfiguration

MissingNameForAdditionalClaim

MissingNameForAdditionalHeader

Other possible deployment errors.

Fault variables

These variables are set when a runtime error occurs. For more information, see What you need to know about policy errors.

Variables Where Example
fault.name="fault_name" fault_name is the name of the fault, as listed in the Runtime errors table above. The fault name is the last part of the fault code. fault.name Matches "TokenExpired"
JWS.failed All JWS policies set the same variable in the case of a failure. jws.JWS-Policy.failed = true

Example error response

For error handling, the best practice is to trap the errorcode part of the error response. Do not rely on the text in the faultstring, because it could change.

Example fault rule

<FaultRules>
    <FaultRule name="JWS Policy Errors">
        <Step>
            <Name>JavaScript-1</Name>
            <Condition>(fault.name Matches "TokenExpired")</Condition>
        </Step>
        <Condition>JWS.failed=true</Condition>
    </FaultRule>
</FaultRules>