Refactor xurl package structure and improve library API#44
Open
drQedwards wants to merge 1 commit intoxdevplatform:mainfrom
Open
Refactor xurl package structure and improve library API#44drQedwards wants to merge 1 commit intoxdevplatform:mainfrom
drQedwards wants to merge 1 commit intoxdevplatform:mainfrom
Conversation
… Go library Refactor package structure so the module root is an importable library (package xurl) instead of package main. Moves CLI entrypoint to cmd/xurl/main.go, updates Makefile and README install paths, and adds library API surface (NewRootCommand, CreateRootCommand, Execute). Also includes --app flag credential switching fix with ForApp token lookups, unconditional WithAppName override, and 18 new tests. Supersedes closed PR xdevplatform#28 (CLA unsigned by prior contributor). Resolves CWE-665: improper initialization of resource.
Author
Build check: "Waiting for status to be reported"The @santiagomed — please check https://github.com/xdevplatform/xurl/actions for a pending approval banner on this PR's workflow run and approve it. Once approved, the Alternatively, since the CLA is now signed and passing, you can merge with admin override if the code looks good. Local verification (already done in codespace):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://cla-assistant.io/xdevplatform/xurl?pullRequest=43 PR #43
This pull request introduces robust multi-app authentication support and improves the developer experience when using the project as a Go library. The most significant changes include ensuring all authentication and token operations are app-aware, adding comprehensive tests for multi-app scenarios, and providing a top-level Go package API for library consumers.
Multi-app authentication enhancements:
Refactored all token store accessors and authentication methods in
auth/auth.goandapi/client.goto use app-specific variants (e.g.,GetOAuth2TokenForApp,GetBearerTokenForApp), ensuring the active app context (set viaWithAppName) is always respected. This prevents cross-app token leakage and guarantees correct credentials are used for each app. [1] [2] [3] [4] [5] [6] [7] [8]Added a new
AppName()getter toauth.Authfor retrieving the current app context.Testing and reliability improvements:
auth/auth_test.goandapi/client_test.goto verify correct token usage, credential overwriting, and app-specific token storage/clearing. These tests validate scenarios such as switching apps, storing tokens for the active app, and ensuring isolation between apps. [1] [2]Go library usability:
Added a new top-level
xurlpackage (xurl.go) that exposesNewRootCommand,CreateRootCommand, andExecutefunctions, making it easy to embed or extend the CLI in other Go projects.Updated the
README.mdto document how to use the project as a Go library and clarified the Go install path for the CLI binary.Build and tooling:
Makefileand Go install instructions to ensure the CLI is built and installed from the correct subdirectory (./cmd/xurl). [1] [2]Other minor improvements:
These changes collectively make the authentication system safer and more predictable in multi-app scenarios, improve test coverage, and enhance the developer experience for both CLI users and Go library consumers.