ramosbugs / openidconnect-rs

OpenID Connect Library for Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to construct LogoutProviderMetadata for an OpenID provider

ronnybremer opened this issue · comments

I would like to extend the current metadata for an OpenID provider by providing an end_session endpoint. According to #111 the ground work is already in place, however, since the struct LogoutProviderMetadata is declared as non-exhaustive I couldn't figure out how to instantiate it when generating the provider metadata.

LogoutProviderMetadata::<EmptyAdditionalProviderMetadata> { end_session_endpoint: xxx }

doesn't work because of that restriction. I couldn't find any implementation for a new() method taking this parameter and I can't implement that on my own for a foreign type.
I have the feeling I am missing something obvious, but I can't figure out how. Any help would be greatly appreciated.

Hey @ronnybremer,

Thanks for raising this issue. When I originally suggested #[non_exhaustive] in #111, I was thinking other logout-related fields might need to be added in the future. However, mixing #[non_exhaustive] with #[serde(flatten)] doesn't really make sense since adding a new field would break backward compatibility with potential existing uses of #[serde(flatten)], even if #[non_exhaustive] prevents breaking changes in instantiating or destructuring the struct.

I think the cleanest fix would be to remove #[non_exhaustive] here. If we ever need to add more fields, it can be done using composition via additional_metadata.

I'll have a fix out shortly.

This is now released in 3.5.0.

Thank you @ramosbugs for your prompt response and fix. Learning Rust ist definitely an experience and some concepts are harder to understand than others. Now I can look into #[serde(flatten)]and figure out what that means :)