feat(cli): pin OIDC callback port via OPENSHELL_OIDC_REDIRECT_PORT#1900
Closed
harry-anderson wants to merge 1 commit into
Closed
feat(cli): pin OIDC callback port via OPENSHELL_OIDC_REDIRECT_PORT#1900harry-anderson wants to merge 1 commit into
harry-anderson wants to merge 1 commit into
Conversation
The OIDC browser login binds an ephemeral loopback port (127.0.0.1:0) for the authorization-code callback. IdPs that require an exact redirect-URI match and do not support a port wildcard (e.g. Okta org authorization servers) reject the random port, so every login fails until the exact port is registered manually. Add OPENSHELL_OIDC_REDIRECT_PORT to pin the callback port, so a single http://127.0.0.1:<port>/callback can be registered with the IdP. Unset, empty, or invalid values fall back to the ephemeral port, preserving existing behavior. Signed-off-by: Harry Anderson <harry.anderson@smartcontract.com>
|
Thank you for your submission! We ask that you sign our Developer Certificate of Origin before we can accept your contribution. You can sign the DCO by adding a comment below using this text: I have read the DCO document and I hereby sign the DCO. You can retrigger this bot by commenting recheck in this Pull Request. Posted by the DCO Assistant Lite bot. |
|
Thank you for your interest in contributing to OpenShell, @harry-anderson. This project uses a vouch system for first-time contributors. Before submitting a pull request, you need to be vouched by a maintainer. To get vouched:
See CONTRIBUTING.md for details. |
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.
Summary
The OIDC browser login binds an ephemeral loopback port (
127.0.0.1:0) for the authorization-code callback. IdPs that require an exact redirect-URI match and do not support a port wildcard reject the random port, so everyopenshell gateway loginfails until that exacthttp://127.0.0.1:<random>/callbackis registered with the IdP by hand.This was hit in practice against an Okta org authorization server (exact redirect matching, no
:*wildcard): each login picked a new port and had to be re-registered in the Okta app before the browser redirect would be accepted.This adds
OPENSHELL_OIDC_REDIRECT_PORTto pin the loopback callback port, so a single stablehttp://127.0.0.1:<port>/callbackcan be registered once with the IdP.Related Issue
None filed. Happy to open one first if preferred per CONTRIBUTING.
Changes
crates/openshell-cli/src/oidc_auth.rs: inoidc_browser_auth_flow, resolve the callback bind address fromOPENSHELL_OIDC_REDIRECT_PORTvia a smalloidc_redirect_bind_addrhelper. When the var holds a validu16port, bind127.0.0.1:<port>; when unset/empty/invalid, fall back to127.0.0.1:0(the existing ephemeral behavior is unchanged).Behavior is fully backward compatible: with the env var unset, the bind address is exactly
127.0.0.1:0as before.Testing
cargo test -p openshell-cli oidc_redirect_bind_addr(helper unit tests).OPENSHELL_OIDC_REDIRECT_PORTset to a pre-registered port,openshell gateway logincompletes without per-login redirect-URI changes.Checklist
mise run pre-commit(run on the contributor's build host)