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

Fix clippy warnings #140

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

l1npengtul
Copy link
Contributor

This PR fixes ~40+ clippy warnings and documentation typos in the main crate, along with many others in the subsequent crates for those using oxide-auth.

This also bumps oxide-auth and all its related crates by 1 minor version to comply with SemVer(lots of Into -> Froms, possible breaking API changes) and to update the oxide-auth to 0.6

  • I have read the [contribution guidelines][Contributing]

I license past and future contributions under the dual MIT/Apache-2.0 license, allowing licensees to chose either at their option.

Copy link
Owner

@HeroicKatora HeroicKatora left a comment

Choose a reason for hiding this comment

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

I can't guarantee that my review was complete. I might revisit it and add more comments, later. This would be easier if you separated

  • style changes
  • SemVer relevant changes as part of naming
  • functional changes such as Pkce's error

The first category is always welcome, if you decide to split the PR then we can bring this quickly and in the process reduce the diff for all remaining changes.

oxide-auth/src/code_grant/authorization.rs Outdated Show resolved Hide resolved
oxide-auth/src/code_grant/extensions/pkce.rs Outdated Show resolved Hide resolved
@@ -27,7 +27,7 @@
//! [`endpoint`]: ../endpoint/index.html
//! [`Endpoint`]: ../endpoint/trait.Endpoint.html

pub mod accesstoken;
pub mod access_token;
Copy link
Owner

Choose a reason for hiding this comment

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

Note to self: Breaking

Copy link
Owner

Choose a reason for hiding this comment

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

We can offer a transitional deprecation by adding an alias mod first:

#[deprecated = "Switch to the new spelling, access_token"]
pub mod accesstoken {
    pub use super::access_token::*;
}

oxide-auth/src/endpoint/access_token.rs Outdated Show resolved Hide resolved
oxide-auth/src/endpoint/mod.rs Outdated Show resolved Hide resolved
oxide-auth/src/code_grant/extensions/pkce.rs Outdated Show resolved Hide resolved
oxide-auth/src/code_grant/extensions/pkce.rs Outdated Show resolved Hide resolved
oxide-auth/src/code_grant/extensions/pkce.rs Outdated Show resolved Hide resolved
oxide-auth/src/code_grant/extensions/pkce.rs Outdated Show resolved Hide resolved
oxide-auth/src/endpoint/mod.rs Outdated Show resolved Hide resolved
Copy link
Owner

@HeroicKatora HeroicKatora 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 dragging my feet on this a small bit since breaking changes seem a bit unfortunate for pure warnings. I'd really rather the breaking changes were a separate PR; and there'd be one last as cleaned-up as possible release. Consider the main goal being security and that updates will reach downstream slowly, the best we can do to speed it up is adding good migration helps but given that the crate was essentially stable for over a year I wouldn't expect fast downstream updates either.

In particular, I aim to have a migration guide covering all breaking changes and it'd be easier to get into the details with separate changes.

Specific actions:

  • Factoring out the PkceError change to a separate PR
  • Providing a deprecated and hidden alias for mod accesstoken
  • Clarity on the two lifetime changes
  • Providing a hidden, deprecated, temporary alias for the wrong spelling privileged_to

Comment on lines +102 to 114
pub fn registrar(&self) -> LockResult<MutexGuard<impl Registrar + Send + 'static>> {
self.registrar.lock()
}

/// Thread-safely access the underlying authorizer, which builds and holds authorization codes.
pub fn authorizer(&self) -> LockResult<MutexGuard<Authorizer + Send + 'static>> {
pub fn authorizer(&self) -> LockResult<MutexGuard<impl Authorizer + Send + 'static>> {
self.authorizer.lock()
}

/// Thread-safely access the underlying issuer, which builds and holds access tokens.
pub fn issuer(&self) -> LockResult<MutexGuard<Issuer + Send + 'static>> {
pub fn issuer(&self) -> LockResult<MutexGuard<impl Issuer + Send + 'static>> {
self.issuer.lock()
}
Copy link
Owner

Choose a reason for hiding this comment

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

I believe these had, and should retain, the semantics of MutexGuard<dyn …>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then I can replace the impl with dyn.

@@ -170,7 +172,7 @@ impl Authorization {
}

/// Go to next state
pub fn advance<'req>(&mut self, input: Input<'req>) -> Output<'_> {
pub fn advance(&mut self, input: Input) -> Output {
Copy link
Owner

Choose a reason for hiding this comment

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

I don't actually know for certain if this is breaking. At face value it looks like this is actually exactly the same. Reference

  • Each elided lifetime in the parameters becomes a distinct lifetime parameter.
  • If the receiver has type &Self or &mut Self, then the lifetime of that reference to Self is assigned to all elided output lifetime parameters.

_ => true,
}
}

/// Determines if this scope has enough privileges to access some resource requiring the scope
/// on the right side. This operation is equivalent to comparison via `>=`.
pub fn priviledged_to(&self, rhs: &Scope) -> bool {
pub fn privileged_to(&self, rhs: &Scope) -> bool {
Copy link
Owner

Choose a reason for hiding this comment

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

Breaking, but can also be solved with a hidden/deprecated method. Weirdly, I have a faint memory of removing this at some point but it may have been somewhere else.

oxide-auth/src/code_grant/refresh.rs Show resolved Hide resolved
@@ -27,7 +27,7 @@
//! [`endpoint`]: ../endpoint/index.html
//! [`Endpoint`]: ../endpoint/trait.Endpoint.html

pub mod accesstoken;
pub mod access_token;
Copy link
Owner

Choose a reason for hiding this comment

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

We can offer a transitional deprecation by adding an alias mod first:

#[deprecated = "Switch to the new spelling, access_token"]
pub mod accesstoken {
    pub use super::access_token::*;
}

@l1npengtul
Copy link
Contributor Author

I can do that, will work on it tomorrow.

@l1npengtul
Copy link
Contributor Author

For the unit error warning, I'll just put #[allow(...)] blocks in front of all of them, should clear it up nicely.

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.

None yet

2 participants