-
Notifications
You must be signed in to change notification settings - Fork 27
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 logic out of the daphne crate #682
Conversation
614b827
to
831b84f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decoupling authorization logic from the daphne crate is a good idea. But if we're taking the time to rework this code, I think we should try to think ahead to how we'd build a multitenant service.
designing for multi-tenancy is not an easy task and depends a lot on how the system is deployed. I believe the best way to design for multi-tenancy in this case is to not design at all. Our internal implementation already has some semblance of multi tenancy going on and it doesn't depend on this implementation to implement it |
21d2e20
to
b3de0a2
Compare
984e278
to
3081ded
Compare
609bda2
to
7e1e246
Compare
One of the intentions of this PR is to distance taskprov from authentication. There are two methods by which an aggregator can determine if the request it receives is authorized:
|
It's a good goal to decouple authentication logic from protocol logic, including taskprov, but I don't think this is the correct way to do it. What this is PR is missing is a notion of "task ownership". Right now whoever knows the peer_auth token has access to all tasks, not necessarily those it has configured. For example, a task we configure manually can be executed by the peer_auth token holder. I don't think this is what we want. The current code has a notion of a "taskprov owner", who has access to all tasks (and only those tasks) configured via taskprov. On the other hand, it can't access a manually configured task unless it knows the bearer token for that task. |
90e2ba1
to
6ff2f1d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good overall. I believe there's one last authentication bug: if the peer presents a valid TLS certificate, it gets access to any task. Mutual TLS is only meant to be available for the taskprov owner at the moment.
24255a4
to
90d60cd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just a few more small things, so here's an early 🦆 .
{ | ||
Ok(()) | ||
} | ||
_ => reject(format_args!("using taskprov")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: If we don't match the first arm because the tokens don't match, then that's an authentication failure. If we don't match because we have a PeerBearerToken::Leader { .. }
but a DapSender::Collector
, then that's a bug, correct? It might be useful to handle the bug as a fatal error rather than an authentication failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes sense. It's likely a configuration error
90d60cd
to
b4bc6fd
Compare
b4bc6fd
to
529e136
Compare
Proposed changes:
remove any notion of authentication from
crates/daphne
This results in:
DapAggregator::unauthorized_reason
being removedDapRequest
to be removed which in turnDapAggregator
,DapLeader
andDapHelper
generic parameters to also be removed.crates/daphne/src/roles/mod.rs
,crates/daphne/src/taskprov.rs
andcrates/daphne/src/testing/mod.rs
Most of the diff in this PR is just removing the generic parameter from all these types
in
crates/daphne-server
Introduce a new method to the
DaphneService
trait called check_bearer_token which can be used in the DapRequestExtractor to guarantee that all requests that are parsed by it are authenticated. A new UnauthenticatedDapRequestExtractor is also included for the cases where we want a DapRequest but don't want to require authentication. Which is the case for upload requests.misc changes
handle_hpke_config_req no longer requires a full
DapRequest
as it only needs theDapVersion
Breaking API change
Unauthorized requests to the helper no longer produce
DapAbort::UnauthorizedRequest
, this is because this error requires aTaskId
but thetask_id
is an optional in theDapRequest
. I could make the task_id optional inUnauthorizedRequest
but I believe thetask_id
inDapRequest
should not be optional at all. This will be fixed in a future PR