From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Shannon Sterz <s.sterz@proxmox.com>
Cc: pdm-devel@lists.proxmox.com
Subject: Re: [pdm-devel] [PATCH proxmox v4 06/21] auth-api: introduce new CreateTicket and CreateTickeReponse api types
Date: Tue, 4 Mar 2025 15:16:41 +0100 [thread overview]
Message-ID: <6qccylnkdjmctkmekjuprhdrwukgm7ekki756jh4dtlalfthjf@pe24qyc432tx> (raw)
In-Reply-To: <20250304120506.135617-7-s.sterz@proxmox.com>
Sorry for missing this but...
On Tue, Mar 04, 2025 at 01:04:51PM +0100, Shannon Sterz wrote:
> these types are used for creating a ticket and responding to a new
> ticket request.
>
> Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
> ---
> proxmox-auth-api/src/types.rs | 56 ++++++++++++++++++++++++++++++++++-
> 1 file changed, 55 insertions(+), 1 deletion(-)
>
> diff --git a/proxmox-auth-api/src/types.rs b/proxmox-auth-api/src/types.rs
> index 64c580a5..81c43ab6 100644
> --- a/proxmox-auth-api/src/types.rs
> +++ b/proxmox-auth-api/src/types.rs
> @@ -417,7 +417,7 @@ impl<'a> TryFrom<&'a str> for &'a TokennameRef {
> }
>
> /// A complete user id consisting of a user name and a realm
> -#[derive(Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd, UpdaterType)]
> +#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Ord, PartialOrd, UpdaterType)]
^ NAK
An empty string is not a valid Userid, so we cannot derive `Default`
here.
There's no such thing as a "default" user id.
> pub struct Userid {
> data: String,
> name_len: usize,
> @@ -676,6 +676,60 @@ impl TryFrom<String> for Authid {
> }
> }
>
> +#[api]
> +/// The parameter object for creating new ticket.
> +#[derive(Debug, Default, Deserialize, Serialize)]
^ For this
> +pub struct CreateTicket {
> + /// User name
> + pub username: Userid,
> +
> + /// The secret password. This can also be a valid ticket. Only optional if the ticket is
> + /// provided in a cookie header and only if the endpoint supports this.
> + #[serde(default)]
> + pub password: Option<String>,
> +
> + /// Verify ticket, and check if user have access 'privs' on 'path'.
> + #[serde(default, skip_serializing_if = "Option::is_none")]
> + pub path: Option<String>,
> +
> + /// Verify ticket, and check if user have access 'privs' on 'path'.
> + #[serde(default, skip_serializing_if = "Option::is_none")]
> + pub privs: Option<String>,
> +
> + /// Port for verifying terminal tickets.
> + #[serde(default, skip_serializing_if = "Option::is_none")]
> + pub port: Option<u16>,
> +
> + /// The signed TFA challenge string the user wants to respond to.
> + #[serde(default, skip_serializing_if = "Option::is_none")]
> + #[serde(rename = "tfa-challenge")]
> + pub tfa_challenge: Option<String>,
> +}
> +
> +#[api]
> +/// The API response for a ticket call.
> +#[derive(Debug, Default, Deserialize, Serialize)]
... and this^
if we need a convenient way to build a struct with "the rest set to
None", just add a method `fn new(username) -> Self` which you use in
place of any `..Default::default()` later on.
> +pub struct CreateTicketResponse {
> + /// The CSRF prevention token.
> + #[serde(default, skip_serializing_if = "Option::is_none")]
> + #[serde(rename = "CSRFPreventionToken")]
> + pub csrfprevention_token: Option<String>,
> +
> + /// The ticket as is supposed to be used in the authentication header. Not provided here if the
> + /// endpoint uses HttpOnly cookies to supply the actual ticket.
> + #[serde(default, skip_serializing_if = "Option::is_none")]
> + pub ticket: Option<String>,
> +
> + /// Like a full ticket, except the signature is missing. Useful in HttpOnly-contexts
> + /// (browsers).
> + #[serde(default, skip_serializing_if = "Option::is_none")]
> + #[serde(rename = "ticket-info")]
> + pub ticket_info: Option<String>,
> +
> + /// The userid.
> + pub username: Userid,
> +}
> +
> #[test]
> fn test_token_id() {
> let userid: Userid = "test@pam".parse().expect("parsing Userid failed");
> --
> 2.39.5
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-03-04 14:16 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-04 12:04 [pdm-devel] [PATCH datacenter-manager/proxmox/yew-comp v4 00/21] use HttpOnly cookies in new projects Shannon Sterz
2025-03-04 12:04 ` [pdm-devel] [PATCH proxmox v4 01/21] time: add new `epoch_to_http_date` helper Shannon Sterz
2025-03-04 12:04 ` [pdm-devel] [PATCH proxmox v4 02/21] rest-server: borrow parts parameter in `get_request_parameter` Shannon Sterz
2025-03-04 12:04 ` [pdm-devel] [PATCH proxmox v4 03/21] router/rest-server: add new `AsyncHttpBodyParameters` api handler type Shannon Sterz
2025-03-04 12:04 ` [pdm-devel] [PATCH proxmox v4 04/21] auth-api: extend `AuthContext` with prefixed cookie name Shannon Sterz
2025-03-04 12:04 ` [pdm-devel] [PATCH proxmox v4 05/21] auth-api: check for new prefixed cookies as well Shannon Sterz
2025-03-04 12:04 ` [pdm-devel] [PATCH proxmox v4 06/21] auth-api: introduce new CreateTicket and CreateTickeReponse api types Shannon Sterz
2025-03-04 14:16 ` Wolfgang Bumiller [this message]
2025-03-07 10:06 ` Maximiliano Sandoval
2025-03-07 10:14 ` Shannon Sterz
2025-03-04 12:04 ` [pdm-devel] [PATCH proxmox v4 07/21] auth-api: add endpoint for issuing tickets as HttpOnly tickets Shannon Sterz
2025-03-04 12:04 ` [pdm-devel] [PATCH proxmox v4 08/21] auth-api: make regular ticket endpoint use the new types and handler Shannon Sterz
2025-03-04 12:04 ` [pdm-devel] [PATCH proxmox v4 09/21] auth-api: add logout method Shannon Sterz
2025-03-04 12:04 ` [pdm-devel] [PATCH proxmox v4 10/21] login: add optional field for ticket_info and make password optional Shannon Sterz
2025-03-04 12:04 ` [pdm-devel] [PATCH proxmox v4 11/21] login: make password optional when creating Login requests Shannon Sterz
2025-03-04 12:04 ` [pdm-devel] [PATCH proxmox v4 12/21] login: add helpers to pass cookie values when parsing login responses Shannon Sterz
2025-03-04 12:04 ` [pdm-devel] [PATCH proxmox v4 13/21] login: add `TicketResult::HttpOnly` member Shannon Sterz
2025-03-04 12:04 ` [pdm-devel] [PATCH proxmox v4 14/21] login: add helper to check whether a ticket is just informational Shannon Sterz
2025-03-04 12:05 ` [pdm-devel] [PATCH proxmox v4 15/21] login: add functions to specify full cookie names Shannon Sterz
2025-03-04 12:05 ` [pdm-devel] [PATCH proxmox v4 16/21] client: add compatibility with HttpOnly cookies Shannon Sterz
2025-03-04 12:05 ` [pdm-devel] [PATCH proxmox v4 17/21] client: specify cookie names for authentication headers where possible Shannon Sterz
2025-03-04 12:05 ` [pdm-devel] [PATCH yew-comp v4 18/21] HttpClient: add helpers to refresh HttpOnly cookies and remove them Shannon Sterz
2025-03-04 12:05 ` [pdm-devel] [PATCH yew-comp v4 19/21] LoginPanel/http helpers: add support for handling HttpOnly cookies Shannon Sterz
2025-03-04 12:05 ` [pdm-devel] [PATCH yew-comp v4 20/21] http helpers: ask server to remove `__Host-` prefixed cookie on logout Shannon Sterz
2025-03-04 12:05 ` [pdm-devel] [PATCH datacenter-manager v4 21/21] api: switch ticket endpoint over to new http only endpoint Shannon Sterz
2025-03-04 14:43 ` [pdm-devel] [PATCH datacenter-manager/proxmox/yew-comp v4 00/21] use HttpOnly cookies in new projects Shannon Sterz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6qccylnkdjmctkmekjuprhdrwukgm7ekki756jh4dtlalfthjf@pe24qyc432tx \
--to=w.bumiller@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
--cc=s.sterz@proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal