Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offer configuration and viewing of images for Oauth2 resources #2665

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ToxicMushroom
Copy link
Collaborator

Fixes #2056

Checklist

  • This pr contains no AI generated code
  • cargo fmt has been run
  • cargo clippy has been run
  • cargo test has been run and passes
  • book chapter included (if relevant)
  • design document included (if relevant)

@ToxicMushroom
Copy link
Collaborator Author

Should I prepend the configured origin set in server.toml together with /ui/images/oauth2/{rs_name} to create the full icon url that AppLink::Oauth2 wants ?

@yaleman
Copy link
Member

yaleman commented Mar 19, 2024

Should I prepend the configured origin set in server.toml together with /ui/images/oauth2/{rs_name} to create the full icon url that AppLink::Oauth2 wants ?

Context would help for this question - the Kanidm client library has make_url which can do this for you, and on the web UI you should be using relative URLs

@ToxicMushroom
Copy link
Collaborator Author

ToxicMushroom commented Mar 19, 2024

sry, it was about the object that gets returned in pub async fn applinks_get
at /v1/self/_applinks
the actual line that should specify the icon url is here
https://github.com/ToxicMushroom/kanidm/blob/097db70c3d4964194fd29f8771b3ee4ed55912bf/server/lib/src/idm/applinks.rs#L59

@ToxicMushroom
Copy link
Collaborator Author

ToxicMushroom commented Mar 19, 2024

But your answer (because this icon field will be used by the web_ui to download the icon) implies that this should return a relative path which a URL is not I think ? Or I'd have to parse the icon url in the web_ui and throw away the host and protocol to make it a rel path.

@yaleman
Copy link
Member

yaleman commented Mar 19, 2024

But your answer (because this icon field will be used by the web_ui to download the icon) implies that this should return a relative path which a URL is not I think ? Or I'd have to parse the icon url in the web_ui and throw away the host and protocol to make it a rel path.

Given this is an as-yet completely unused feature, we can define what it is right now in this PR 😄 Realistically since the URL is based on the name (/ui/images/oauth2/{rs_name}) and the name is in the applink struct already, that icon field could just be a bool called has_custom_icon which means the webUI accesses /ui/images/oauth2/{rs_name} to get the image.

@ToxicMushroom
Copy link
Collaborator Author

I'm still gonna add an admin web interface for it but the current code can already be reviewed if you want to review it in smaller parts :)

@@ -113,6 +98,53 @@ pub async fn do_request<JV: AsRef<JsValue>>(
Ok((kopid, status, body, headers))
}

/// Build and send a request to the backend, with some standard headers and pull back
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this

requested_rem,
rem
);
security_error!("requested_rem: {:?} !⊆ allowed: {:?}", requested_rem, rem);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What version of rust are you on? Looks like cargo fmt fights here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rustc 1.77.0-nightly (5518eaa94 2024-01-29)

let name = name.clone();
spawn_local(async move {
let (_, status, blob, _) =
get_blob(format!("/ui/images/oauth2/{name}").as_str()).await.unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theres a server uri handler for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ToxicMushroom
Copy link
Collaborator Author

I discussed with yaleman on the matrix channel about the blob stuff I'm using atm:
Since we have an existing carveout for the data: scheme because of bootstrap, we thought it'd be best to just use that instead with base64 image data instead of adding blob: to the CSP.
So I'll refactor that part to use base64 and the server to return base64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

Set custom image/icon for applications
3 participants