Conversation
|
Docker build validation completed after refreshing the CI-style bookworm moxygen bundle:
Result: Docker image built successfully as |
|
Adding some unwritten documentation so I can understand the flow -- other reviewers may find helpful: Startup: YAML → Runtime ObjectsConnection Time: CLIENT_SETUP → Session AuthPer-Request: Subscribe / Publish / Fetch / etc.Session Teardown |
Auth Module Review:
|
Auth Config ReviewPattern ConsistencyThe structure follows existing conventions well. One inconsistency: every optional field in afrind: should we also support hmac key files? This can be done as a follow up unless its trivial here since there's already a lot going on. CriticalZero test coverage for all auth config validation and resolution
Important
Description strings for auth booleans don't document their defaults |
Auth Wiring Review: Relay + Context + ServerWhat changedServer layer ( Context layer (
Relay layer (
Correctness
Simplicity / Moxygen Follow-upThe Recommendation: Add a
The 6 Test Coverage
|
suhasHere
left a comment
There was a problem hiding this comment.
Thanks for the work on this @mondain . here are few high level thoughts. Can we split this PR into 3 parts
- Auth Config
- Abstract Auth API
- CAT Auth bits.
On the last one, was wondering if you got chance to checkout this repo : https://github.com/Quicr/catapult
It implements cat4moq and dpop with all the crypto bits . I would encourage us to use this library instead of reinventing the wheel , if possible.
@suhasHere made 1 comment.
Reviewable status: 0 of 17 files reviewed, all discussions resolved (waiting on afrind, akash-a-n, gmarzot, michalhosna, Oxyd, peterchave, and TimEvens).
mondain
left a comment
There was a problem hiding this comment.
@suhasHere I'll do a deeper dive into catapult, I'm all for not reinventing the wheel and on the surface it looks good to me.
@mondain made 1 comment.
Reviewable status: 0 of 17 files reviewed, all discussions resolved (waiting on afrind, akash-a-n, gmarzot, michalhosna, Oxyd, peterchave, and TimEvens).
|
Docker focused validation passed:
The Docker test configure needed the same gflags workaround used by the local build script: -DCMAKE_FIND_LIBRARY_SUFFIXES=".so;.a"
-DGFLAGS_SHARED=ON |
I'm creating a separate PR off this work to provide the route for Catapult; separating the original PR into n new PR does not excite me for several reasons, but I'll go with the group, if others think its prudent. |
afrind
left a comment
There was a problem hiding this comment.
Ok, many small comments I'm sure claude can handle. I don't think this really needs a further split. It is a big review but I made it through. @suhasHere are you ok with catapult as a follow up?
@afrind reviewed 18 files and all commit messages, and made 18 comments.
Reviewable status: all files reviewed, 13 unresolved discussions (waiting on akash-a-n, gmarzot, michalhosna, mondain, Oxyd, peterchave, and TimEvens).
deps/moxygen line 1 at r3 (raw file):
Subproject commit 36c314edb9b42345fd4ad918b463743edad21a87
What moxygen change is required to support this?
CMakeLists.txt line 38 at r3 (raw file):
find_package(moxygen REQUIRED) find_package(OpenSSL REQUIRED)
Everyone cool with OpenSSL dep here? @suhasHere
config.example.yaml line 60 at r3 (raw file):
# auth: # Optional: enable CAT-style authorization for this service # enabled: true # token_type: 0 # MOQT AUTHORIZATION_TOKEN token type
token_type 0 is reserved to mean "nothing" in the spec? So I think we cannot specify 0 (config loader should error)
config.example.yaml line 64 at r3 (raw file):
# - id: "key-1" # secret: "replace-with-secret" # require_setup_token: true
Do each of these need descriptive comments? I'm not sure what the convention is
src/MoqxRelay.cpp line 133 at r3 (raw file):
} auto session = MoQSession::getRequestSession();
Can we pass the session in? Seems like it's already known/needed elsewhere
src/MoqxRelay.cpp line 134 at r3 (raw file):
auto session = MoQSession::getRequestSession(); auto token = authVerifier_.allowRequestTokenOverride()
If override is not on and the request does contain a new token, should we log/error? Or it's expected behavior?
src/MoqxRelay.cpp line 142 at r3 (raw file):
return folly::makeUnexpected(grants.error()); } if (auth::allows(grants.value(), action, ns, trackName)) {
Seems like we could have a single auth::allows call by consolidating this bit with below. eg:
if (token) {
grants = verify();
} else {
grants = sessionAuth_.find();
}
if (!auth::allows(...)) {
}
src/MoqxRelay.cpp line 257 at r3 (raw file):
auto authRes = authorize(auth::Action::PublishNamespace, pubNs.params, pubNs.trackNamespace); if (authRes.hasError()) { co_return folly::makeUnexpected(PublishNamespaceError{
I think we should log in all these branches - maybe DBG1?
src/auth/Auth.h line 72 at r3 (raw file):
folly::Expected<Grants, AuthError> verify(const moxygen::AuthToken& token) const; // Internal v1 envelope used by tests and by local token issuers:
Hm, maybe this could be in a subclass? Also "local token issuers"?
src/auth/Auth.h line 87 at r3 (raw file):
const Grants& grants, Action action, const moxygen::TrackNamespace& ns,
Maybe split into two signatures, TrackNamespace and FullTrackName, that both call allowsImpl with this signature?
src/auth/Auth.cpp line 93 at r3 (raw file):
uint32_t readU32BE(std::string_view data, size_t offset) { return (static_cast<uint32_t>(static_cast<unsigned char>(data[offset])) << 24) |
is this just an implement of ntohl or folly::endian::big/little?
src/auth/Auth.cpp line 99 at r3 (raw file):
} void appendU32BE(std::string& out, uint32_t value) {
Same you can do this with a helper to flop your integer and then memcpy, right?
src/auth/Auth.cpp line 137 at r3 (raw file):
} class CborReader {
Minor preference to move CborReader to its own file in case we ever need it for something else.
src/auth/Auth.cpp line 179 at r3 (raw file):
uint8_t major = 0; uint64_t len = 0; if (!readType(major, len) || (major != 2 && major != 3) || len > data_.size() - pos_) {
Can we add symbolic constants throughout for these magic numbers?
src/auth/Auth.cpp line 315 at r3 (raw file):
} bool parseScope(CborReader& reader, Scope& scope) {
A comment describing the format would make it easier to validate the code is correct for the non-cat experts
src/auth/Auth.cpp line 473 at r3 (raw file):
const auto nsBytes = canonicalNamespace(ns); const auto trackBytes = trackName.value_or(std::string_view()); for (const auto& scope : grants.scopes) {
Can this be a potential performance concern? Could someone supply a token with a large number of scopes? I suppose it's bound by the MOQT 64k control message len limit, but would a hash lookup be better?
test/config/ConfigResolverTest.cpp line 467 at r3 (raw file):
cfg.services.value().clear(); auto auth = makeAuthConfig(); auth.token_type = std::optional<uint64_t>{uint64_t{1} << 62};
How will we remember to adjust this when we go to MOQT varints?
Summary
Adds opt-in CAT-style token authentication and authorization for MOQT relay services.
Changes
Notes
This PR uses the existing feature/auth branch contents as requested, including branch-local commits outside the auth implementation commit.
Validation
This change is