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

feat(): validated oob invitation #287

Closed
wants to merge 2 commits into from

Conversation

Christiantyemele
Copy link
Collaborator

No description provided.

@Christiantyemele Christiantyemele linked an issue Dec 18, 2024 that may be closed by this pull request
let plaintext =
to_string(oob_message).map_err(|e| format!("Serialization error: {}", e))?;
let encoded_jwm = Base64Url.encode(plaintext.as_bytes());

Ok(format!("{}?_oob={}", url, encoded_jwm))
let ooburl = format!("{}/_oob{}", url, encoded_jwm);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You changed the format of the oob_url. Is there any reason to that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes i want to use the oob jwm as a routing path to the out band message and the previous format contains query parameters which will be misinterpreted if used as route path

Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't have to do what you plan to do. Plus, note that the OOB URL format is normative. Check https://identity.foundation/didcomm-messaging/spec/#standard-message-encoding.

crates/web-plugins/oob-messages/src/models.rs Outdated Show resolved Hide resolved
crates/web-plugins/oob-messages/src/plugin.rs Show resolved Hide resolved
Router::new() //
.route("/oob_url", get(handler_oob_inv))
.route("/oob_qr", get(handler_oob_qr))
.route("/", get(handler_landing_page_oob))
// handle oob invitation to invitation message
.route(&invitation_path, get(decode_oob_inv))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I dont understand what the new route is and why you added it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The qr_code and and oob url have no handled route, what i mean is if you can the oob qr_code you get nothing even the oob_url takes you no where as the route has not been handled and as such you can have its content without decoding it, that's where this route comes in

Copy link
Collaborator

Choose a reason for hiding this comment

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

The oob_url should not necessarily take you to somewhere.

Copy link
Collaborator

@Blindspot22 Blindspot22 left a comment

Choose a reason for hiding this comment

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

Apart from the changes @Hermann-Core requested, I think this PR's good to go.

@Christiantyemele Christiantyemele self-assigned this Jan 6, 2025
Copy link
Collaborator

@IngridPuppet IngridPuppet left a comment

Choose a reason for hiding this comment

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

This PR changes the OOB URL into a format that is not normative. I left some comments regarding that and other points. Please, could you check?

Comment on lines +234 to +236
let url = format!("{}", server_public_domain);
let encoded_oob = OobMessage::serialize_oob_message(&oobmessage, &url).unwrap();
encoded_oob
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add an assert_eq! to validate what you expect as valid output.

Router::new() //
.route("/oob_url", get(handler_oob_inv))
.route("/oob_qr", get(handler_oob_qr))
.route("/", get(handler_landing_page_oob))
// handle oob invitation to invitation message
.route(&invitation_path, get(decode_oob_inv))
Copy link
Collaborator

Choose a reason for hiding this comment

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

The oob_url should not necessarily take you to somewhere.

crates/web-plugins/oob-messages/src/models.rs Show resolved Hide resolved
let plaintext =
to_string(oob_message).map_err(|e| format!("Serialization error: {}", e))?;
let encoded_jwm = Base64Url.encode(plaintext.as_bytes());

Ok(format!("{}?_oob={}", url, encoded_jwm))
let ooburl = format!("{}/_oob{}", url, encoded_jwm);
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't have to do what you plan to do. Plus, note that the OOB URL format is normative. Check https://identity.foundation/didcomm-messaging/spec/#standard-message-encoding.

Comment on lines +275 to +277
let serialized_msg = test_serialize_oobmessage();
let oobmessage: Vec<&str> = serialized_msg.split("/_oob").collect();
let oobmessage = oobmessage.get(1).unwrap().to_string();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that _oob must be a query parameter in a compliant OOB URL.

Comment on lines +68 to 74
let oobmessage: Vec<&str> = oob_inv.split("/_").collect();
let oobmessage = oobmessage.get(1).unwrap_or(&"").to_string();

self.state = Some(OOBMessagesState {
filesystem: Arc::new(Mutex::new(fs)),
oobmessage,
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • I don't see the point of extracting something like "oob=abcd...xyz", when you already have the full string...
  • Did you run cargo clippy on your changes? I feel like you can use unwrap_or_default here.

Comment on lines +47 to +49
<body>
<a href={}>out of band invitation url</a>
</body>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please leave the URL plainly visible. It is more practical that way. See https://mediator.rootsid.cloud.

Comment on lines +23 to +24
let html_content =
match retrieve_or_generate_oob_inv(&mut *fs, &server_public_domain, &storage_dirpath) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you rename this variable? I don't think it contains anything HTML.

Comment on lines +57 to +61
pub(crate) async fn decode_oob_inv(State(state): State<Arc<OOBMessagesState>>) -> Response {
let encoded_inv = &state.oobmessage;
let encoded_inv: Vec<&str> = encoded_inv.split("oob").collect();
let encoded_inv = encoded_inv.get(1).unwrap();
let decoded_inv = Base64Url.decode(encoded_inv).unwrap_or_default();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not seeing the purpose of this handler... Do you have any valid use case?

crates/web-plugins/oob-messages/src/models.rs Show resolved Hide resolved
let plaintext =
to_string(oob_message).map_err(|e| format!("Serialization error: {}", e))?;
let encoded_jwm = Base64Url.encode(plaintext.as_bytes());

Ok(format!("{}?_oob={}", url, encoded_jwm))
let ooburl = format!("{}/_oob{}", url, encoded_jwm);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let ooburl = format!("{}/_oob{}", url, encoded_jwm);
let oob_url = format!("{}/_oob{}", url, encoded_jwm);

Comment on lines +121 to 122
let url: &String = &format!("{}", server_public_domain);
let oob_url = OobMessage::serialize_oob_message(&oob_message, url)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The conversion here is unnecessary.

Suggested change
let url: &String = &format!("{}", server_public_domain);
let oob_url = OobMessage::serialize_oob_message(&oob_message, url)
let oob_url = OobMessage::serialize_oob_message(&oob_message, server_public_domain)

Comment on lines +276 to +277
let oobmessage: Vec<&str> = serialized_msg.split("/_oob").collect();
let oobmessage = oobmessage.get(1).unwrap().to_string();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let oobmessage: Vec<&str> = serialized_msg.split("/_oob").collect();
let oobmessage = oobmessage.get(1).unwrap().to_string();
let oob_message: Vec<&str> = serialized_msg.split("/_oob").collect();
let oob_message = oobmessage.get(1).unwrap().to_string();

}

#[derive(Clone)]
pub(crate) struct OOBMessagesState {
pub(crate) filesystem: Arc<Mutex<dyn FileSystem>>,
pub(crate) oobmessage: String,
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is the purpose of the field you added here?

let server_public_domain = std::env::var("SERVER_PUBLIC_DOMAIN").unwrap();
let storage_dirpath = std::env::var("STORAGE_DIRPATH").unwrap();
let mut fs = MockFileSystem;
let oobmessage =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let oobmessage =
let oob_message =

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 have check all the comments and from our discussions it seems this PR actually solves no issue or brings and adjustments so, i guess it should be closed @Hermann-Core @IngridPuppet

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would agree. Also check the comment I left on the issue before planning to close it as well.

@chendiblessing chendiblessing deleted the 286-validate-oob-invitation branch January 16, 2025 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate OOB invitation
5 participants