Basis-Theory / azure-keyvault-emulator

https://basistheory.com
Apache License 2.0
31 stars 4 forks source link

Set correct scope expected by SDK #145

Closed david-marconis closed 5 months ago

david-marconis commented 5 months ago

Description

Change the scope in the authentication challenge to match the (Python) SDK requirements.

The scope should be on the form https://vault.azure.net/.default. More info on scopes Here.

Here is the code in the python SDK that requires this: bilde The scope is parsed as a url on line 116, and it is compared against the request URL on line 121.

-

Testing required outside of automated testing?

Here is a small test example using the azure.keyvaylt.secrets library:

from azure.core.credentials import AccessToken, TokenCredential
from azure.keyvault.secrets import SecretClient

class LocalCredential(TokenCredential):
    def get_token(self, *args, **kwargs) -> AccessToken:
        return AccessToken("eyJhbGciOiJub25lIn0.eyJzdWIiOiIxIn0.", 9223372036854775807)

s = SecretClient("https://localhost.vault.azure.net:5551", LocalCredential())

print(s.get_secret("foo").value)

Previously it would give me the error

The challenge contains invalid scope 'foobar'.

Screenshots (if appropriate):

Rollback / Rollforward Procedure

Reviewer Checklist

bt-platform-eng commented 5 months ago

:tada: This PR is included in version 1.2.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: