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: added WIP apikey request guard #185

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

feat: added WIP apikey request guard #185

wants to merge 1 commit into from

Conversation

ErikBjare
Copy link
Member

No description provided.

@ErikBjare ErikBjare marked this pull request as draft November 8, 2020 16:02
@codecov
Copy link

codecov bot commented Nov 8, 2020

Codecov Report

Merging #185 (da279fa) into master (65e28bf) will increase coverage by 0.18%.
The diff coverage is 60.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #185      +/-   ##
==========================================
+ Coverage   59.67%   59.86%   +0.18%     
==========================================
  Files          42       42              
  Lines        4308     4313       +5     
==========================================
+ Hits         2571     2582      +11     
+ Misses       1737     1731       -6     
Impacted Files Coverage Δ
aw-server/src/endpoints/cors.rs 100.00% <ø> (ø)
aw-server/src/endpoints/mod.rs 100.00% <ø> (+3.33%) ⬆️
aw-server/src/config.rs 45.20% <60.00%> (+1.08%) ⬆️
aw-query/src/parser.rs 38.90% <0.00%> (+0.15%) ⬆️
aw-datastore/src/datastore.rs 74.15% <0.00%> (+0.30%) ⬆️
aw-datastore/src/worker.rs 75.95% <0.00%> (+0.69%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65e28bf...da279fa. Read the comment docs.

Copy link
Member

@johan-bjareholt johan-bjareholt left a comment

Choose a reason for hiding this comment

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

What is this supposed to solve?
Won't the API key be exposed since we are not using HTTPS?

let keys: Vec<_> = request.headers().get("x-api-key").collect();
match keys.len() {
0 => Outcome::Failure((Status::BadRequest, ApiKeyError::Missing)),
1 if apikey == keys[0] => Outcome::Success(ApiKey(Some(keys[0].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.

That's a very convoluted way of expressing it.
Better to just have a single case for one and have the of statement inside a block.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, just picked it straight from the example.

@ErikBjare
Copy link
Member Author

ErikBjare commented Nov 8, 2020

@johan-bjareholt I've explained the reasoning for why it's needed in the docstring for auth.rs

But yes, the key will be exposed if not used with HTTPS. However, for Android apps it's still an improvement (since I assume they can't snoop on local packets however they like).

@johan-bjareholt
Copy link
Member

However, for Android apps it's still an improvement (since I assume they can't snoop on local packets however they like).

Aha, that makes sense.

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