|
22 | 22 | import google.api_core.gapic_v1.client_info |
23 | 23 | import google.api_core.gapic_v1.config |
24 | 24 | import google.api_core.gapic_v1.method |
| 25 | +import google.api_core.gapic_v1.routing_header |
25 | 26 | import google.api_core.grpc_helpers |
26 | 27 | import google.api_core.path_template |
27 | 28 | import grpc |
@@ -267,6 +268,19 @@ def generate_access_token( |
267 | 268 | request = common_pb2.GenerateAccessTokenRequest( |
268 | 269 | name=name, scope=scope, delegates=delegates, lifetime=lifetime |
269 | 270 | ) |
| 271 | + if metadata is None: |
| 272 | + metadata = [] |
| 273 | + metadata = list(metadata) |
| 274 | + try: |
| 275 | + routing_header = [("name", name)] |
| 276 | + except AttributeError: |
| 277 | + pass |
| 278 | + else: |
| 279 | + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( |
| 280 | + routing_header |
| 281 | + ) |
| 282 | + metadata.append(routing_metadata) |
| 283 | + |
270 | 284 | return self._inner_api_calls["generate_access_token"]( |
271 | 285 | request, retry=retry, timeout=timeout, metadata=metadata |
272 | 286 | ) |
@@ -349,6 +363,19 @@ def generate_id_token( |
349 | 363 | delegates=delegates, |
350 | 364 | include_email=include_email, |
351 | 365 | ) |
| 366 | + if metadata is None: |
| 367 | + metadata = [] |
| 368 | + metadata = list(metadata) |
| 369 | + try: |
| 370 | + routing_header = [("name", name)] |
| 371 | + except AttributeError: |
| 372 | + pass |
| 373 | + else: |
| 374 | + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( |
| 375 | + routing_header |
| 376 | + ) |
| 377 | + metadata.append(routing_metadata) |
| 378 | + |
352 | 379 | return self._inner_api_calls["generate_id_token"]( |
353 | 380 | request, retry=retry, timeout=timeout, metadata=metadata |
354 | 381 | ) |
@@ -424,6 +451,19 @@ def sign_blob( |
424 | 451 | request = common_pb2.SignBlobRequest( |
425 | 452 | name=name, payload=payload, delegates=delegates |
426 | 453 | ) |
| 454 | + if metadata is None: |
| 455 | + metadata = [] |
| 456 | + metadata = list(metadata) |
| 457 | + try: |
| 458 | + routing_header = [("name", name)] |
| 459 | + except AttributeError: |
| 460 | + pass |
| 461 | + else: |
| 462 | + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( |
| 463 | + routing_header |
| 464 | + ) |
| 465 | + metadata.append(routing_metadata) |
| 466 | + |
427 | 467 | return self._inner_api_calls["sign_blob"]( |
428 | 468 | request, retry=retry, timeout=timeout, metadata=metadata |
429 | 469 | ) |
@@ -499,6 +539,19 @@ def sign_jwt( |
499 | 539 | request = common_pb2.SignJwtRequest( |
500 | 540 | name=name, payload=payload, delegates=delegates |
501 | 541 | ) |
| 542 | + if metadata is None: |
| 543 | + metadata = [] |
| 544 | + metadata = list(metadata) |
| 545 | + try: |
| 546 | + routing_header = [("name", name)] |
| 547 | + except AttributeError: |
| 548 | + pass |
| 549 | + else: |
| 550 | + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( |
| 551 | + routing_header |
| 552 | + ) |
| 553 | + metadata.append(routing_metadata) |
| 554 | + |
502 | 555 | return self._inner_api_calls["sign_jwt"]( |
503 | 556 | request, retry=retry, timeout=timeout, metadata=metadata |
504 | 557 | ) |
@@ -543,20 +596,25 @@ def generate_identity_binding_access_token( |
543 | 596 | (https://tools.ietf.org/html/rfc7523) and must have 'kid' field in the |
544 | 597 | header. Supported signing algorithms: RS256 (RS512, ES256, ES512 coming |
545 | 598 | soon). Mandatory payload fields (along the lines of RFC 7523, section |
546 | | - 3): - iss: issuer of the token. Must provide a discovery document at |
547 | | - $iss/.well-known/openid-configuration . The document needs to be |
548 | | - formatted according to section 4.2 of the OpenID Connect Discovery 1.0 |
549 | | - specification. - iat: Issue time in seconds since epoch. Must be in the |
550 | | - past. - exp: Expiration time in seconds since epoch. Must be less than |
551 | | - 48 hours after iat. We recommend to create tokens that last shorter than |
552 | | - 6 hours to improve security unless business reasons mandate longer |
553 | | - expiration times. Shorter token lifetimes are generally more secure |
554 | | - since tokens that have been exfiltrated by attackers can be used for a |
555 | | - shorter time. you can configure the maximum lifetime of the incoming |
556 | | - token in the configuration of the mapper. The resulting Google token |
557 | | - will expire within an hour or at "exp", whichever is earlier. - sub: JWT |
558 | | - subject, identity asserted in the JWT. - aud: Configured in the mapper |
559 | | - policy. By default the service account email. |
| 599 | + 3): |
| 600 | +
|
| 601 | + - iss: issuer of the token. Must provide a discovery document at |
| 602 | + $iss/.well-known/openid-configuration . The document needs to be |
| 603 | + formatted according to section 4.2 of the OpenID Connect Discovery |
| 604 | + 1.0 specification. |
| 605 | + - iat: Issue time in seconds since epoch. Must be in the past. |
| 606 | + - exp: Expiration time in seconds since epoch. Must be less than 48 |
| 607 | + hours after iat. We recommend to create tokens that last shorter than |
| 608 | + 6 hours to improve security unless business reasons mandate longer |
| 609 | + expiration times. Shorter token lifetimes are generally more secure |
| 610 | + since tokens that have been exfiltrated by attackers can be used for |
| 611 | + a shorter time. you can configure the maximum lifetime of the |
| 612 | + incoming token in the configuration of the mapper. The resulting |
| 613 | + Google token will expire within an hour or at "exp", whichever is |
| 614 | + earlier. |
| 615 | + - sub: JWT subject, identity asserted in the JWT. |
| 616 | + - aud: Configured in the mapper policy. By default the service account |
| 617 | + email. |
560 | 618 |
|
561 | 619 | Claims from the incoming token can be transferred into the output token |
562 | 620 | accoding to the mapper configuration. The outgoing claim size is |
@@ -606,6 +664,19 @@ def generate_identity_binding_access_token( |
606 | 664 | request = common_pb2.GenerateIdentityBindingAccessTokenRequest( |
607 | 665 | name=name, scope=scope, jwt=jwt |
608 | 666 | ) |
| 667 | + if metadata is None: |
| 668 | + metadata = [] |
| 669 | + metadata = list(metadata) |
| 670 | + try: |
| 671 | + routing_header = [("name", name)] |
| 672 | + except AttributeError: |
| 673 | + pass |
| 674 | + else: |
| 675 | + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( |
| 676 | + routing_header |
| 677 | + ) |
| 678 | + metadata.append(routing_metadata) |
| 679 | + |
609 | 680 | return self._inner_api_calls["generate_identity_binding_access_token"]( |
610 | 681 | request, retry=retry, timeout=timeout, metadata=metadata |
611 | 682 | ) |
0 commit comments