From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 2812E70C67 for ; Fri, 25 Jun 2021 13:41:46 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 16D2C179B6 for ; Fri, 25 Jun 2021 13:41:16 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 7E643179AA for ; Fri, 25 Jun 2021 13:41:15 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 53A8E466A9 for ; Fri, 25 Jun 2021 13:41:15 +0200 (CEST) Date: Fri, 25 Jun 2021 13:41:13 +0200 From: Wolfgang Bumiller To: Dietmar Maurer Cc: pbs-devel@lists.proxmox.com Message-ID: <20210625114113.lod2dtzqncranq5i@wobu-vie.proxmox.com> References: <20210625092050.2329182-1-dietmar@proxmox.com> <20210625092050.2329182-6-dietmar@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210625092050.2329182-6-dietmar@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.715 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [openid.rs] Subject: Re: [pbs-devel] [PATCH proxmox-backup v3 05/10] cli: add CLI to manage openid realms. X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jun 2021 11:41:46 -0000 just a minor cleanup: On Fri, Jun 25, 2021 at 11:20:45AM +0200, Dietmar Maurer wrote: > diff --git a/src/bin/proxmox_backup_manager/openid.rs b/src/bin/proxmox_backup_manager/openid.rs > new file mode 100644 > index 00000000..13915339 > --- /dev/null > +++ b/src/bin/proxmox_backup_manager/openid.rs > @@ -0,0 +1,99 @@ > +use anyhow::Error; > +use serde_json::Value; > + > +use proxmox::api::{api, cli::*, RpcEnvironment, ApiHandler}; > + > +use proxmox_backup::{config, api2, api2::types::REALM_ID_SCHEMA}; > + > + > +#[api( > + input: { > + properties: { > + "output-format": { > + schema: OUTPUT_FORMAT, > + optional: true, > + }, > + } > + } > +)] > +/// List configured OpenId realms > +fn list_openid_realms(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result { > + > + let output_format = get_output_format(¶m); > + > + let info = &api2::config::access::openid::API_METHOD_LIST_OPENID_REALMS; > + let mut data = match info.handler { > + ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?, > + _ => unreachable!(), > + }; > + > + let options = default_table_format_options() > + .column(ColumnConfig::new("realm")) > + .column(ColumnConfig::new("issuer-url")) > + .column(ColumnConfig::new("comment")); > + > + format_and_print_result_full(&mut data, &info.returns, &output_format, &options); > + > + Ok(Value::Null) > +} > +#[api( > + input: { > + properties: { > + realm: { > + schema: REALM_ID_SCHEMA, > + }, > + "output-format": { > + schema: OUTPUT_FORMAT, > + optional: true, > + }, > + } > + } > +)] > + > +/// Show OpenID realm configuration > +fn show_openid_realm(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result { > + > + let output_format = get_output_format(¶m); > + > + let info = &api2::config::access::openid::API_METHOD_READ_OPENID_REALM; > + let mut data = match info.handler { > + ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?, > + _ => unreachable!(), > + }; > + > + let options = default_table_format_options(); > + format_and_print_result_full(&mut data, &info.returns, &output_format, &options); > + > + Ok(Value::Null) > +} > + > +pub fn openid_commands() -> CommandLineInterface { > + > + let cmd_def = CliCommandMap::new() > + .insert("list", CliCommand::new(&&API_METHOD_LIST_OPENID_REALMS)) > + .insert("show", CliCommand::new(&&API_METHOD_SHOW_OPENID_REALM) > + .arg_param(&["realm"]) > + .completion_cb("realm", config::domains::complete_openid_realm_name) > + ) > + .insert("create", > + CliCommand::new(&api2::config::access::openid::API_METHOD_CREATE_OPENID_REALM) > + .arg_param(&["realm"]) > + .arg_param(&["realm"]) ^ this line is duplicated > + .completion_cb("realm", config::domains::complete_openid_realm_name) > + ) > + .insert("update", > + CliCommand::new(&api2::config::access::openid::API_METHOD_UPDATE_OPENID_REALM) > + .arg_param(&["realm"]) > + .arg_param(&["realm"]) ^ this line is duplicated > + .completion_cb("realm", config::domains::complete_openid_realm_name) > + ) > + .insert("delete", > + CliCommand::new(&api2::config::access::openid::API_METHOD_DELETE_OPENID_REALM) > + .arg_param(&["realm"]) > + .arg_param(&["realm"]) ^ this line is duplicated > + .completion_cb("realm", config::domains::complete_openid_realm_name) > + ) > + ; > + > + cmd_def.into() > +}