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

Major upgrade and refactor #15

Merged
merged 21 commits into from
Jun 11, 2024
Merged

Major upgrade and refactor #15

merged 21 commits into from
Jun 11, 2024

Conversation

masongup-mdsol
Copy link
Member

Changes include:

  • Integrate with standardized mauth-core lib for crypto operations
    • No more direct dependency on crypto crates
    • This crate mostly expresses standardized integration with other Rust crates for making and receiving requests
  • Refactor - split out code into separate files
  • Swap Travis for GHA
  • Standard Clippy and Rustfmt CI
  • Remove obsolete response verification
  • Take advantage of reqwest crate features for improved API - no longer need to use helpers with the request body

@@ -12,23 +12,24 @@ approval for the full stack used through the Architecture and Security groups.
```rust
let mauth_info = MAuthInfo::from_default_file().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this example should include the use statements or maybe we should have an examples/main.rs file with something that compiles and works

Copy link
Member Author

Choose a reason for hiding this comment

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

Note that this is generated from this doc test which is compiled as part of the CI test suite.

Making an example that works is problematic, since that would require an actual MAuth URL and valid private key to be stored in this public repo. I suppose I can modify it to allow the use statements to be shown though.

Ok(())
}

pub(crate) fn set_headers_v2(&self, req: &mut Request, signature: String, timestamp_str: &str) {
Copy link
Contributor

Choose a reason for hiding this comment

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

does this need to be available in the whole crate?

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically yes, the protocol test suite tests need access to it to test that the headers get set correctly. I'm not sure if there's a good way to provide access just to that.

}

impl MAuthInfo {
pub(crate) async fn validate_request(
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to have some test.

These validate functions require an Axum Request, while the signing requests require a reqWest Request.
I know reqWest is the most popular high level client library, not sure about Axum as the community (last time I checked 1 year ago) is fragmented.

Potentially we could use http:request everywhere but I do not know how much of PITA that would be.

Copy link
Member Author

Choose a reason for hiding this comment

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

I found it impossible to build a version based on the http crate's request trait because there is no interface provided to allow you to read the contents of the body without consuming it and making it unavailable to the rest of the stack. Constructing a new body with the request data is also not possible, as the concrete type would be unknown and there is no method on the trait to create a new instance. If you can figure out a way to do this, I'd love to know!

Axum is not a dominantly popular Rust web framework. However, to the best of my knowledge, it is the only one integrated with the Tower ecosystem that makes it at least theoretically possible to build reusable and composable middleware like this. To have a working request verifier with any other currently existing Rust web framework would require a complete rewrite anyways to use the interfaces provided by that specific web framework.

Copy link
Contributor

@jcarres-mdsol jcarres-mdsol left a comment

Choose a reason for hiding this comment

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

I'm satisfied with the answers, maybe we want to wait for Yohei to give it a last review

@jcarres-mdsol jcarres-mdsol merged commit 6c2abc7 into master Jun 11, 2024
4 checks passed
@jcarres-mdsol jcarres-mdsol deleted the convert-to-mauth-core branch June 11, 2024 18:43
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.

2 participants