Skip to content

Conversation

woodruffw
Copy link
Member

@woodruffw woodruffw commented Jun 21, 2022

WIP.

This adds more debug logs and adds the SIGSTORE_OAUTH_BROWSER environment variable, which can be used to override the webbrowser's default browser selection (e.g. SIGSTORE_OAUTH_BROWSER=firefox).

Removed the SIGSTORE_OAUTH_BROWSER variable, since it's essentially a duplicate of what webbrowser already does via the BROWSER variable. Instead, this PR adds SIGSTORE_OAUTH_FORCE_OOB, which forcefully disables the in-band OAuth flow if set.

See #96.

Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
@kushaldas
Copy link

I am seeing:

I replaced the real values for {AUTH_CODE_VALUE}&state={MYSTATE_VALUE}

DEBUG:sigstore._internal.oidc.oauth:GET: /auth/callback?code={AUTH_CODE_VALUE}&state={MYSTATE_VALUE}
DEBUG:sigstore._internal.oidc.oauth:GET: /favicon.ico
DEBUG:sigstore._internal.oidc.oauth:GET: /favicon.ico
DEBUG:sigstore._internal.oidc.oauth:GET: /favicon.ico
DEBUG:sigstore._internal.oidc.oauth:GET: /favicon.ico
DEBUG:sigstore._internal.oidc.oauth:GET: /favicon.ico
DEBUG:sigstore._internal.oidc.oauth:GET: /favicon.ico
DEBUG:sigstore._internal.oidc.oauth:GET: /favicon.ico
DEBUG:sigstore._internal.oidc.oauth:GET: /favicon.ico
DEBUG:sigstore._internal.oidc.oauth:GET: /favicon.ico
DEBUG:sigstore._internal.oidc.oauth:GET: /favicon.ico
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): oauth2.sigstore.dev:443
DEBUG:urllib3.connectionpool:https://oauth2.sigstore.dev:443 "POST /auth/token HTTP/1.1" 400 70
Traceback (most recent call last):
  File "/home/kdas/code/sigstore-python/sigstore/_internal/oidc/oauth.py", line 211, in get_identity_token
    resp.raise_for_status()
  File "/home/kdas/code/sigstore-python/.venv/lib64/python3.10/site-packages/requests/models.py", line 1022, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://oauth2.sigstore.dev/auth/token

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib64/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/kdas/code/sigstore-python/sigstore/__main__.py", line 22, in <module>
    main()
  File "/home/kdas/code/sigstore-python/sigstore/_cli.py", line 254, in main
    _sign(args)
  File "/home/kdas/code/sigstore-python/sigstore/_cli.py", line 333, in _sign
    args.identity_token = get_identity_token(
  File "/home/kdas/code/sigstore-python/sigstore/_internal/oidc/oauth.py", line 213, in get_identity_token
    raise IdentityError from http_error
sigstore._internal.oidc.IdentityError

@woodruffw
Copy link
Member Author

woodruffw commented Jun 21, 2022 via email

Signed-off-by: William Woodruff <william@trailofbits.com>
@woodruffw
Copy link
Member Author

@kushaldas could you try once more with the changes in 91b22a0? That should prevent any races if the browser attempts to spam us with favicon requests.

@kushaldas
Copy link

@kushaldas could you try once more with the changes in 91b22a0? That should prevent any races if the browser attempts to spam us with favicon requests.

DEBUG:sigstore._internal.oidc.oauth:GET: /auth/callback?code={AUTH_CODE_VALUE}&state={MYSTATE_VALUE}
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): oauth2.sigstore.dev:443
DEBUG:urllib3.connectionpool:https://oauth2.sigstore.dev:443 "POST /auth/token HTTP/1.1" 400 70
Traceback (most recent call last):
  File "/home/kdas/code/sigstore-python/sigstore/_internal/oidc/oauth.py", line 219, in get_identity_token
    resp.raise_for_status()
  File "/home/kdas/code/sigstore-python/.venv/lib64/python3.10/site-packages/requests/models.py", line 1022, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://oauth2.sigstore.dev/auth/token

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib64/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/kdas/code/sigstore-python/sigstore/__main__.py", line 22, in <module>
    main()
  File "/home/kdas/code/sigstore-python/sigstore/_cli.py", line 254, in main
    _sign(args)
  File "/home/kdas/code/sigstore-python/sigstore/_cli.py", line 333, in _sign
    args.identity_token = get_identity_token(
  File "/home/kdas/code/sigstore-python/sigstore/_internal/oidc/oauth.py", line 221, in get_identity_token
    raise IdentityError from http_error
sigstore._internal.oidc.IdentityError

Btw, I am on the slack in #python channel, just in case if you want to have a chat :)

Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
Signed-off-by: William Woodruff <william@trailofbits.com>
@woodruffw woodruffw requested review from tetsuo-cpp and di June 21, 2022 18:51
@woodruffw
Copy link
Member Author

This should be good to go. It "fixes" the idempotency issue by doing one less call to server.auth_request(). That's not ideal in the long term, however, since the API is still pretty easy to misuse. We should think about making it more misuse-resistant.

Signed-off-by: William Woodruff <william@trailofbits.com>
@woodruffw woodruffw merged commit 96d7de2 into main Jun 21, 2022
@woodruffw woodruffw deleted the ww/oauth-debug branch June 21, 2022 19:42
This was referenced Jun 21, 2022
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.

3 participants