`google.api.Service` config seems to require an audience to avoid JWT validation errors
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 38/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- api, authentication
Línea de trabajo
Comienza con endpoints/bookstore-grpc/api_config_auth.yaml y endpoints/bookstore-grpc-transcoding/api_config_auth.yaml; después revisa jwt_token_gen.py y bookstore_client.py para comprobar el flujo de autenticación. Reproduce la solicitud JWT descrita en el issue y verifica que ambas configuraciones de servicio acepten la autenticación prevista de la cuenta de servicio sin el error de validación de la audiencia.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
In which file did you encounter the issue?
Did you change the file? If so, how?
Yes, in the following section of the files:
#
# Request authentication.
#
authentication:
providers:
- id: google_service_account
# Replace SERVICE-ACCOUNT-ID with your service account's email address.
issuer: SERVICE-ACCOUNT-ID
jwks_uri: https://www.googleapis.com/robot/v1/metadata/x509/SERVICE-ACCOUNT-ID
rules:
# This auth rule will apply to all methods.
- selector: "*"
requirements:
- provider_id: google_service_account
I added an audience field to the config:
#
# Request authentication.
#
authentication:
providers:
- id: google_service_account
# Replace SERVICE-ACCOUNT-ID with your service account's email address.
issuer: SERVICE-ACCOUNT-ID
jwks_uri: https://www.googleapis.com/robot/v1/metadata/x509/SERVICE-ACCOUNT-ID
audiences: DEFAULT_HOSTNAME
rules:
# This auth rule will apply to all methods.
- selector: "*"
requirements:
- provider_id: google_service_account
Describe the issue
When using current api_config_auth.yaml for service-account JWT authentication I continued to get "{"message":"Audiences in Jwt are not allowed","code":403}". This error was present regardless of whether the JWT I passed had an audience. I used jwt_token_gen.py to generate the JWTs to pass when reaching out to the api python3 bookstore_client.py --auth_token JWT_TOKEN --host= DEFAULT_HOSTNAME --port 443 --use_tls true.
To generate a JWT without an audience field I commented out the 'aud' portion of the payload in jwt_token_gen.py . I tried without an audience and with the service name as an audience and each test provided the same error message. I inspected each JWT in jwt.io to ensure that each JWT claim was how I expected.
Overall, I suspect the google.api.Service spec has a different behavior for expected audiences than the OpenAPI spec (which doesn't required audience). Adding audience to the config resolved the issue and allowed me to hit the API with service-account JWT authentication enabled. Willing to create a PR to incorporate audiences: DEFAULT_HOSTNAME if approved 👍
- Lenguaje dominante
- Jupyter Notebook
- Estrellas
- 8.1k
- Forks
- 6.7k
- Merge medio
- 4 d 4 h
- PR fusionados (30 d)
- 8
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de GoogleCloudPlatform/python-docs-samples
-
samples
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
GoogleCloudPlatform/python-docs-samples#14609 ·
Los mantenedores suelen responder en 1 día
-
samples
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
GoogleCloudPlatform/python-docs-samples#14610 ·
Los mantenedores suelen responder en 1 día
-
samples
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
GoogleCloudPlatform/python-docs-samples#14611 ·
Los mantenedores suelen responder en 1 día
-
samples
GoogleCloudPlatform/python-docs-samples#14117 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
samples
GoogleCloudPlatform/python-docs-samples#14091 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de GoogleCloudPlatform/python-docs-samples
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
diegosouzapw/OmniRoute#14869 ·
Los mantenedores suelen responder en 1 día
-
clawsweeper:needs-maintainer-review clawsweeper:needs-product-decision clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:other issue-rating: 🦞 diamond lobster P2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
steipete/CodexBar#4008 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
auth: ServiceAccountCredentials silently ignores quota_project_id in service account JSON files Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
googleapis/google-cloud-swift#1194 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
gradio-app/gradio#13895 ·
Los mantenedores suelen responder en 1 día
-
bug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día