Skip to content

Cleanup interfaces of http requests and /token#202

Merged
avalerio-tkd merged 6 commits into
mainfrom
av_auth_023
Dec 19, 2025
Merged

Cleanup interfaces of http requests and /token#202
avalerio-tkd merged 6 commits into
mainfrom
av_auth_023

Conversation

@avalerio-tkd

Copy link
Copy Markdown
Collaborator
  • Cleanups and small refactors for /token endpoint and client http requests.

@argmarco-tkd argmarco-tkd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for this. Overall LGTM. Left a few relatively minor comments. No need for a new PR unless you need me to.

Comment thread src/common/json_request.h Outdated
struct TokenRequest {
std::string client_id;
std::string api_key;
std::optional<std::string> error_message;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

wait, error_message in the Request object?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You're right, that's an overlook. It's an attempt to compile JsonRequest / Token / Response. Will rework it a bit and ping back.

Comment thread src/server/auth_utils.cpp Outdated

// GenerateJWT implementation
std::optional<std::string> ClientCredentialStore::GenerateJWT(const std::string& client_id, const std::string& api_key) const {
std::optional<std::pair<std::string, std::int64_t>> ClientCredentialStore::GenerateJWT(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can wait for a later iteration, but should 'Token' be a more complex type which also contains the 'expiration time' ? (rather than keeping the concepts together via a pair)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, was attempting to not add too many structs around. Will rework a bit these classes. Thanks for the comments.

Comment thread src/server/auth_utils_test.cpp Outdated
auto response2 = store.ProcessTokenRequest(valid_json2);
EXPECT_TRUE(response2.token.has_value());
EXPECT_FALSE(response2.token.value().empty());
EXPECT_TRUE(response2.expires_at.has_value());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

where are we testing that expires_at has, well, a 'proper' value? Is that in an upcoming PR?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added it, then removed it. Will add it back again.

@avalerio-tkd

Copy link
Copy Markdown
Collaborator Author

Ok, finally cleaned up lots of nits. Merging..

@avalerio-tkd avalerio-tkd merged commit 2ce9e55 into main Dec 19, 2025
2 checks passed
@avalerio-tkd avalerio-tkd deleted the av_auth_023 branch December 19, 2025 06:40
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