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

Move authentication middleware to new scope #14

Merged
merged 3 commits into from
Aug 6, 2022

Conversation

trueleo
Copy link
Contributor

@trueleo trueleo commented Aug 6, 2022

Description

BasicAuth middleware was wrapped around entire application causing people to authenticate twice.
This PR fixes this by moving all endpoints under base path to a new scope then wrapping it in the BasicAuth middleware
Now the static files served under root path do not require authentication.

@trueleo trueleo changed the title Middleware fix Move authentication middleware to new scope Aug 6, 2022
}

fn readiness_path() -> String {
format!("{}/readiness", base_path())
"/readiness".to_string()
Copy link
Member

Choose a reason for hiding this comment

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

How will it get the base path?

}

fn liveness_path() -> String {
format!("{}/liveness", base_path())
"/liveness".to_string()
Copy link
Member

Choose a reason for hiding this comment

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

same as above

}

fn query_path() -> String {
format!("{}/query", base_path())
"/query".to_string()
Copy link
Member

Choose a reason for hiding this comment

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

same as above

.service(ResourceFiles::new("/", generated));
cfg.service(
// Base path "{url}/api/v1"
web::scope(&base_path())
Copy link
Contributor Author

@trueleo trueleo Aug 6, 2022

Choose a reason for hiding this comment

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

@nitisht base path is used inside this web::scope thus every path grouped underneath it will share same base url i.e /api/v1. I changed the related functions to not return full path.

Copy link
Member

Choose a reason for hiding this comment

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

ah okay..we need to test all the APIs then, just to make sure nothing is broken

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep

@nitisht nitisht merged commit 3011834 into parseablehq:main Aug 6, 2022
@trueleo trueleo deleted the middleware_fix branch August 6, 2022 13:10
@ProgrammerShri
Copy link
Contributor

Looking forward to it...
@trueleo

Good Job

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.

3 participants