bug(python): OIDC refresh drops the gateway's oidc_scopes
Les mainteneurs répondent en général sous 1 jour
@jyotir07 y travaille déjà.
Depuis le 26/10/2026.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 84/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- python
- Domaine
- authentication
Piste de recherche
Commencez par _OidcRefresher._refresh dans python/openshell/sandbox.py et comparez le format de son jeton avec le chemin d’actualisation de la CLI décrit dans l’issue. Lisez le traitement des métadonnées de gateway à proximité, puis exécutez les tests ciblés du refresher dans python/openshell/sandbox_test.py. Le travail est terminé lorsque les tests montrent que la requête inclut des valeurs de oidc_scopes séparées par des espaces lorsqu’elles sont présentes et reste inchangée lorsqu’elles sont absentes.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
User Story
As a student building a personal project that creates and drives OpenShell sandboxes from the Python SDK (SandboxClient.from_active_cluster), I want the SDK to refresh my OIDC session the same way the CLI does, so that my scripts keep working after the access token expires without me running a CLI command to renew it.
I noticed the Python refresh behaving differently from the CLI while working on the project. Comparing the two refresh paths showed that the Python refresher never sends the gateway's oidc_scopes, and I then reproduced it with a unit test.
Problem Statement
_OidcRefresher._refresh in python/openshell/sandbox.py posts the refresh_token grant with only grant_type, refresh_token, and client_id. It never sends the gateway's oidc_scopes. The CLI does send them (ensure_valid_oidc_token_bundle → oidc_refresh_token(..., scopes)), and the docs say refresh uses "the OIDC scopes saved in the gateway metadata". The Python client-credentials provider in the same file already reads oidc_scopes / oidc_audience from metadata; only the refresh path omits them.
Impact / Why This Matters
With identity providers that require scope on the refresh grant, or that pick the token's resource from it (for example Microsoft Entra ID), the Python SDK's first automatic refresh fails or returns a token the gateway rejects. The same gateway works with the CLI. The current workaround is to run openshell gateway login or a CLI command before the token expires so the CLI rewrites oidc_token.json. That does not work for long-running Python processes.
Acceptance Criteria
- When gateway metadata has
oidc_scopes, the Python refresh request includesscope=<space-separated scopes>, matching the CLI. - Without
oidc_scopes, the refresh request is unchanged. - A unit test covers both cases.
Reproduction Steps
- Register a gateway whose
metadata.jsonhas"auth_mode": "oidc"and"oidc_scopes": "openid api://openshell/.default", with an expired access token and a valid refresh token inoidc_token.json. - Build the provider with
_make_cluster_bearer_provider(gateway_dir, name)(the pathSandboxClient.from_active_clusteruses) and call it once, with the refresher'shttpx.Clientbound to anhttpx.MockTransportthat records the token request. - The posted form contains
grant_type,refresh_token, andclient_id, but noscope. The CLI's refresh for the same gateway sendsscope=openid api://openshell/.default.
Suggested UX (if applicable)
No response
Environment
- OpenShell:
main@ c4688aa8 - SDK: Python (
python/openshell/sandbox.py,_OidcRefresher)
Logs
FAILED python/openshell/sandbox_test.py::test_refresher_sends_gateway_oidc_scopes
E AssertionError: assert None == 'openid api://openshell/.default'
- Langage dominant
- Rust
- Étoiles
- 20.6k
- Forks
- 2k
- Merge moyen
- 2 j 13 h
- PR mergées (30 j)
- 262
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de NVIDIA/OpenShell
-
config preflight exits 0 on allow_unauthenticated_users = truePeut-être pris @ericcurtin l’a pris il y a 1 jour. Ouvertestate:triage-needed
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
Les mainteneurs répondent en général sous 1 jour
-
state:triage-needed
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
Les mainteneurs répondent en général sous 1 jour
-
bug: workspace access hint suggests a --subject command that fails for hyphen-leading OIDC subjectsPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de NVIDIA/OpenShell
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
could docs good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
README em inglêsOuvertegood first issue help wanted priority:p2 type:docs
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
lucacasanova/homedeck#122 ·
-
needs-triage
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
bherbruck/solvecraft#11729 · 1 commentaire · 1 réaction ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour