Skip to content

Conversation

@dborovcanin
Copy link
Collaborator

@dborovcanin dborovcanin commented Nov 25, 2025

What type of PR is this?

This is a feature.

What does this do?

It adds an OAuth support to SMQ CLI.

Which issue(s) does this PR fix/relate to?

Resolves #3222.

Have you included tests for your changes?

Yes.

Did you document any new/modified feature?

Yes.

Notes

N/A

@dborovcanin dborovcanin force-pushed the oauth-cli branch 2 times, most recently from 4d0c18c to d89aabc Compare November 25, 2025 10:30
@dborovcanin dborovcanin changed the title NOISSUE - Add OAuth support to CLI SMQ-3222 - Add OAuth support to CLI Nov 25, 2025
@dborovcanin dborovcanin force-pushed the oauth-cli branch 2 times, most recently from db6fbe7 to b0c2226 Compare November 25, 2025 19:36
@dborovcanin dborovcanin marked this pull request as ready for review November 26, 2025 11:17
@dborovcanin dborovcanin requested a review from a team as a code owner November 26, 2025 11:17
@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

❌ Patch coverage is 45.01348% with 204 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.85%. Comparing base (eb83edb) to head (85af9fb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/sdk/mocks/sdk.go 0.00% 99 Missing ⚠️
users/api/oauth.go 63.20% 42 Missing and 4 partials ⚠️
cli/oauth.go 56.56% 40 Missing and 3 partials ⚠️
cli/users.go 28.57% 10 Missing ⚠️
pkg/sdk/tokens.go 79.31% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3255      +/-   ##
==========================================
+ Coverage   35.55%   39.85%   +4.29%     
==========================================
  Files         307       64     -243     
  Lines       39314    15077   -24237     
==========================================
- Hits        13979     6009    -7970     
+ Misses      24477     8674   -15803     
+ Partials      858      394     -464     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

cli/oauth.go Outdated
shutdownTimeout = 5 * time.Second
)

const successHTML = `<!DOCTYPE html>
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we have the preview.html files can we remove this constants and use embed library

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed preview files and move strings to a separate go file. We are trying to use approach as simple as possible, and also standalone since this is something that will be running on Users end - i.e. we start a small server used for redirection. We are not even using it as a template, as you can see, but just serve it as a string with HTML content type.

nyagamunene
nyagamunene previously approved these changes Nov 26, 2025
Copy link
Contributor

@nyagamunene nyagamunene left a comment

Choose a reason for hiding this comment

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

LGTM

@arvindh123
Copy link
Contributor

arvindh123 commented Nov 27, 2025

@dborovcanin
I think CLI should open the SuperMQ Login page in browser and then user should choose the oauth
Where SuperMQ UI or backend should capable of redirecting to CLI server

We can take reference flow from Digital ocean doctl cli tool and Github CLI tool

@dborovcanin
Copy link
Collaborator Author

@arvindh123 What we can do is use Device Auth Flow instead https://datatracker.ietf.org/doc/html/rfc8628. I have a draft prepared, but haven't sent it yet.

@dborovcanin
Copy link
Collaborator Author

@arvindh123 The reason is simple - there is no reason to assume device using CLI has broweser installed. For example, you could and are likely to use CLI when SSH-ed to the cloud component.

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.

Add OAuth support to CLI

3 participants