|
12 | 12 | // See the License for the specific language governing permissions and |
13 | 13 | // limitations under the License. |
14 | 14 |
|
15 | | -use base64::encode_config; |
16 | | -use base64::URL_SAFE_NO_PAD; |
| 15 | +use base64::engine::general_purpose; |
| 16 | +use base64::prelude::*; |
17 | 17 | use common_base::base::tokio; |
18 | 18 | use common_exception::Result; |
19 | 19 | use common_meta_app::principal::AuthInfo; |
@@ -41,8 +41,9 @@ struct NonCustomClaims { |
41 | 41 | fn get_jwks_file_rs256(kid: &str) -> (RS256KeyPair, String) { |
42 | 42 | let key_pair = RS256KeyPair::generate(2048).unwrap().with_key_id(kid); |
43 | 43 | let rsa_components = key_pair.public_key().to_components(); |
44 | | - let e = encode_config(rsa_components.e, URL_SAFE_NO_PAD); |
45 | | - let n = encode_config(rsa_components.n, URL_SAFE_NO_PAD); |
| 44 | + |
| 45 | + let e = general_purpose::URL_SAFE_NO_PAD.encode(rsa_components.e); |
| 46 | + let n = general_purpose::URL_SAFE_NO_PAD.encode(rsa_components.n); |
46 | 47 | let j = |
47 | 48 | serde_json::json!({"keys": [ {"kty": "RSA", "kid": kid, "e": e, "n": n, } ] }).to_string(); |
48 | 49 | (key_pair, j) |
@@ -193,8 +194,8 @@ async fn test_auth_mgr_with_jwt() -> Result<()> { |
193 | 194 | let kid = "test_kid"; |
194 | 195 | let key_pair = RS256KeyPair::generate(2048)?.with_key_id(kid); |
195 | 196 | let rsa_components = key_pair.public_key().to_components(); |
196 | | - let e = encode_config(rsa_components.e, URL_SAFE_NO_PAD); |
197 | | - let n = encode_config(rsa_components.n, URL_SAFE_NO_PAD); |
| 197 | + let e = general_purpose::URL_SAFE_NO_PAD.encode(rsa_components.e); |
| 198 | + let n = general_purpose::URL_SAFE_NO_PAD.encode(rsa_components.n); |
198 | 199 | let j = |
199 | 200 | serde_json::json!({"keys": [ {"kty": "RSA", "kid": kid, "e": e, "n": n, } ] }).to_string(); |
200 | 201 |
|
@@ -424,8 +425,8 @@ async fn test_auth_mgr_with_jwt_es256() -> Result<()> { |
424 | 425 | let encoded_point = |
425 | 426 | EncodedPoint::from_bytes(key_pair.public_key().public_key().to_bytes_uncompressed()) |
426 | 427 | .expect("must be valid encode point"); |
427 | | - let x = encode_config(encoded_point.x().unwrap(), URL_SAFE_NO_PAD); |
428 | | - let y = encode_config(encoded_point.y().unwrap(), URL_SAFE_NO_PAD); |
| 428 | + let x = general_purpose::URL_SAFE_NO_PAD.encode(encoded_point.x().unwrap()); |
| 429 | + let y = general_purpose::URL_SAFE_NO_PAD.encode(encoded_point.y().unwrap()); |
429 | 430 | let j = |
430 | 431 | serde_json::json!({"keys": [ {"kty": "EC", "kid": kid, "x": x, "y": y, } ] }).to_string(); |
431 | 432 |
|
@@ -651,8 +652,8 @@ async fn test_jwt_auth_mgr_with_management() -> Result<()> { |
651 | 652 | let user_name = "test"; |
652 | 653 | let key_pair = RS256KeyPair::generate(2048)?.with_key_id(kid); |
653 | 654 | let rsa_components = key_pair.public_key().to_components(); |
654 | | - let e = encode_config(rsa_components.e, URL_SAFE_NO_PAD); |
655 | | - let n = encode_config(rsa_components.n, URL_SAFE_NO_PAD); |
| 655 | + let e = general_purpose::URL_SAFE_NO_PAD.encode(rsa_components.e); |
| 656 | + let n = general_purpose::URL_SAFE_NO_PAD.encode(rsa_components.n); |
656 | 657 | let j = |
657 | 658 | serde_json::json!({"keys": [ {"kty": "RSA", "kid": kid, "e": e, "n": n, } ] }).to_string(); |
658 | 659 |
|
|
0 commit comments