feat: updates
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||
use jwt::{AlgorithmType, Header, ToBase64};
|
||||
use rust_util::util_clap::{Command, CommandError};
|
||||
use rust_util::XResult;
|
||||
use serde_json::{Map, Value};
|
||||
|
||||
use crate::cmd_sign_jwt::{build_jwt_parts, merge_header_claims, merge_payload_claims};
|
||||
use crate::cmd_sign_jwt::{build_jwt_parts, merge_header_claims, merge_payload_claims, print_jwt_token};
|
||||
use crate::keychain::{KeychainKey, KeychainKeyValue};
|
||||
use crate::{cmd_sign_jwt, cmdutil, digest, ecdsautil, hmacutil, keychain, rsautil, util};
|
||||
|
||||
@@ -29,8 +27,6 @@ impl Command for CommandImpl {
|
||||
fn run(&self, _arg_matches: &ArgMatches, sub_arg_matches: &ArgMatches) -> CommandError {
|
||||
let json_output = cmdutil::check_json_output(sub_arg_matches);
|
||||
|
||||
let mut json = BTreeMap::<&'_ str, String>::new();
|
||||
|
||||
let private_key = opt_value_result!(
|
||||
sub_arg_matches.value_of("private-key"),
|
||||
"Private key PKCS#8 DER base64 encoded or PEM"
|
||||
@@ -57,17 +53,8 @@ impl Command for CommandImpl {
|
||||
let (header, payload, jwt_claims) = build_jwt_parts(sub_arg_matches)?;
|
||||
|
||||
let token_string = sign_jwt(&private_key, header, &payload, &jwt_claims)?;
|
||||
print_jwt_token(json_output, token_string);
|
||||
|
||||
debugging!("Singed JWT: {}", token_string);
|
||||
if json_output {
|
||||
json.insert("token", token_string.clone());
|
||||
} else {
|
||||
success!("Singed JWT: {}", token_string);
|
||||
}
|
||||
|
||||
if json_output {
|
||||
println!("{}", serde_json::to_string_pretty(&json).unwrap());
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user