<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 配置 為了簡化庫的設置,jwt提供了類`Lcobucci\JWT\Configuration`. 它的目的是: * 配置要使用的默認算法(簽名者)和密鑰 * 配置默認的驗證約束集 * 為[擴展點提供自定義實現 * 檢索組件(編碼器、解碼器、解析器、驗證器和構建器) ## 用法 為了使用它,您必須: 1. 初始化配置對象 2. 自定義配置對象 3. 檢索組件 ### 配置初始化 該`Lcobucci\JWT\Signer\Key\InMemory`對象用于對稱/非對稱簽名。 要初始化它,您可以將關鍵內容作為純文本傳遞: ~~~php use Lcobucci\JWT\Signer\Key\InMemory; $key = InMemory::plainText('my-key-as-plaintext'); ~~~ 提供一個 base64 編碼的字符串: ~~~php use Lcobucci\JWT\Signer\Key\InMemory; $key = InMemory::base64Encoded('YSB2ZXJ5IGxvbmcgYSB2ZXJ5IHVsdHJhIHNlY3VyZSBrZXkgZm9yIG15IGFtYXppbmcgdG9rZW5z'); ~~~ 或者提供一個文件路徑: ~~~php use Lcobucci\JWT\Signer\Key\InMemory; use Lcobucci\JWT\Signer\Key\LocalFileReference; $key = InMemory::file(__DIR__ . '/stored.pem'); // 這將讀取文件并將其內容保留在內存中 $key = LocalFileReference::file(__DIR__ . '/stored.pem'); // 這只是保留對文件的引用 ~~~ #### 對于對稱算法 對稱算法使用相同的密鑰進行簽名創建和驗證。這意味著您的密鑰**保持機密**非常重要。 **建議您使用具有大量熵的密鑰,最好使用加密安全的偽隨機數生成器 (CSPRNG) 生成。您可以使用[CryptoKey](https://github.com/AndrewCarterUK/CryptoKey)工具為您執行此操作。** ~~~php use Lcobucci\JWT\Configuration; use Lcobucci\JWT\Signer\Hmac\Sha256; use Lcobucci\JWT\Signer\Key\InMemory; $configuration = Configuration::forSymmetricSigner( //您可以使用任何HMAC變體(256、384和512) new Sha256(), // 用您自己的密鑰替換下面的值! InMemory::base64Encoded('mBC5v1sOKVvbdEitdSBenu59nfNfhwkedkJVNabosTw=') // 您還可以通過在此處提供額外參數來覆蓋JOSE編碼器/解碼器 ); ~~~ #### 對于非對稱算法 非對稱算法使用**私鑰**創建簽名,使用**公鑰**進行驗證。這意味著可以分發您的**public key**。但是,**私鑰**應該**保密**。 ~~~php use Lcobucci\JWT\Configuration; use Lcobucci\JWT\Signer; use Lcobucci\JWT\Signer\Key\LocalFileReference; use Lcobucci\JWT\Signer\Key\InMemory; $configuration = Configuration::forAsymmetricSigner( // 您可以在Curve25519上使用RSA或ECDSA及其所有變體(256、384和512)和EdDSA new Signer\Rsa\Sha256(), LocalFileReference::file(__DIR__ . '/private.pem'), InMemory::base64Encoded('mBC5v1sOKVvbdEitdSBenu59nfNfhwkedkJVNabosTw=') // 您還可以通過在此處提供額外參數來覆蓋JOSE編碼器/解碼器 ); ~~~ ## *提示* ECDSA 算法的實現具有構造函數依賴性。使用`create()`命名構造函數來避免處理它(例如:)`Lcobucci\JWT\Signer\Ecdsa\Sha256::create()`。 #### 對于沒有算法 警告 **不**建議將此配置類型用于生產環境。它只是為了讓人們可以更簡單、更快速地設置測試,避免任何類型的簽名創建/驗證。 ~~~php use Lcobucci\JWT\Configuration; $configuration = Configuration::forUnsecuredSigner( // 你還可以通過在此處提供額外參數來覆蓋JOSE編碼器/解碼器 ); ~~~ ### 定制 通過使用 的設置器,`Lcobucci\JWT\Configuration`您可以自定義此庫的設置。 重要的 如果您想使用自定義配置,請確保在調用任何 getter 之前調用 setter。否則,將使用默認實現。 這些是可用的 setter: * `Lcobucci\JWT\Configuration#setBuilderFactory()`: 配置令牌構建器的創建方式 * `Lcobucci\JWT\Configuration#setParser()`:配置自定義令牌解析器 * `Lcobucci\JWT\Configuration#setValidator()`: 配置自定義驗證器 * `Lcobucci\JWT\Configuration#setValidationConstraints()`: 配置默認的驗證約束集 ### 檢索組件 完成所有必要的配置后,您可以在代碼周圍傳遞配置對象并使用 getter 來檢索組件: 這些是可用的吸氣劑: * `Lcobucci\JWT\Configuration#builder()`:檢索令牌構建器(始終創建新實例) * `Lcobucci\JWT\Configuration#parser()`: 檢索令牌解析器 * `Lcobucci\JWT\Configuration#signer()`: 檢索簽名者 * `Lcobucci\JWT\Configuration#signingKey()`: 檢索創建簽名的密鑰 * `Lcobucci\JWT\Configuration#verificationKey()`: 檢索簽名驗證的密鑰 * `Lcobucci\JWT\Configuration#validator()`: 檢索令牌驗證器 * `Lcobucci\JWT\Configuration#validationConstraints()`: 檢索默認的驗證約束集
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看