Skip to content

Commit 6945437

Browse files
feat: [google-cloud-kms] support Key Access Justifications policy configuration (#12808)
BEGIN_COMMIT_OVERRIDE feat: support Key Access Justifications policy configuration END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. PiperOrigin-RevId: 643369736 Source-Link: googleapis/googleapis@311e0ce Source-Link: googleapis/googleapis-gen@ba77501 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWttcy8uT3dsQm90LnlhbWwiLCJoIjoiYmE3NzUwMTk0ZTgzNWJhYjE5NWI2M2JlZTU2NTdjODY1NjkwMTg3NCJ9 --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: ohmayr <[email protected]>
1 parent 9318d94 commit 6945437

File tree

5 files changed

+143
-0
lines changed

5 files changed

+143
-0
lines changed

packages/google-cloud-kms/google/cloud/kms/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@
6262
VerifyConnectivityResponse,
6363
)
6464
from google.cloud.kms_v1.types.resources import (
65+
AccessReason,
6566
CryptoKey,
6667
CryptoKeyVersion,
6768
CryptoKeyVersionTemplate,
6869
ExternalProtectionLevelOptions,
6970
ImportJob,
71+
KeyAccessJustificationsPolicy,
7072
KeyOperationAttestation,
7173
KeyRing,
7274
ProtectionLevel,
@@ -155,9 +157,11 @@
155157
"CryptoKeyVersionTemplate",
156158
"ExternalProtectionLevelOptions",
157159
"ImportJob",
160+
"KeyAccessJustificationsPolicy",
158161
"KeyOperationAttestation",
159162
"KeyRing",
160163
"PublicKey",
164+
"AccessReason",
161165
"ProtectionLevel",
162166
"AsymmetricDecryptRequest",
163167
"AsymmetricDecryptResponse",

packages/google-cloud-kms/google/cloud/kms_v1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@
5555
VerifyConnectivityResponse,
5656
)
5757
from .types.resources import (
58+
AccessReason,
5859
CryptoKey,
5960
CryptoKeyVersion,
6061
CryptoKeyVersionTemplate,
6162
ExternalProtectionLevelOptions,
6263
ImportJob,
64+
KeyAccessJustificationsPolicy,
6365
KeyOperationAttestation,
6466
KeyRing,
6567
ProtectionLevel,
@@ -116,6 +118,7 @@
116118
"AutokeyAsyncClient",
117119
"EkmServiceAsyncClient",
118120
"KeyManagementServiceAsyncClient",
121+
"AccessReason",
119122
"AsymmetricDecryptRequest",
120123
"AsymmetricDecryptResponse",
121124
"AsymmetricSignRequest",
@@ -157,6 +160,7 @@
157160
"GetPublicKeyRequest",
158161
"ImportCryptoKeyVersionRequest",
159162
"ImportJob",
163+
"KeyAccessJustificationsPolicy",
160164
"KeyHandle",
161165
"KeyManagementServiceClient",
162166
"KeyOperationAttestation",

packages/google-cloud-kms/google/cloud/kms_v1/types/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@
4343
VerifyConnectivityResponse,
4444
)
4545
from .resources import (
46+
AccessReason,
4647
CryptoKey,
4748
CryptoKeyVersion,
4849
CryptoKeyVersionTemplate,
4950
ExternalProtectionLevelOptions,
5051
ImportJob,
52+
KeyAccessJustificationsPolicy,
5153
KeyOperationAttestation,
5254
KeyRing,
5355
ProtectionLevel,
@@ -128,9 +130,11 @@
128130
"CryptoKeyVersionTemplate",
129131
"ExternalProtectionLevelOptions",
130132
"ImportJob",
133+
"KeyAccessJustificationsPolicy",
131134
"KeyOperationAttestation",
132135
"KeyRing",
133136
"PublicKey",
137+
"AccessReason",
134138
"ProtectionLevel",
135139
"AsymmetricDecryptRequest",
136140
"AsymmetricDecryptResponse",

packages/google-cloud-kms/google/cloud/kms_v1/types/resources.py

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
package="google.cloud.kms.v1",
2727
manifest={
2828
"ProtectionLevel",
29+
"AccessReason",
2930
"KeyRing",
3031
"CryptoKey",
3132
"CryptoKeyVersionTemplate",
@@ -34,6 +35,7 @@
3435
"PublicKey",
3536
"ImportJob",
3637
"ExternalProtectionLevelOptions",
38+
"KeyAccessJustificationsPolicy",
3739
},
3840
)
3941

@@ -66,6 +68,90 @@ class ProtectionLevel(proto.Enum):
6668
EXTERNAL_VPC = 4
6769

6870

71+
class AccessReason(proto.Enum):
72+
r"""Describes the reason for a data access. Please refer to
73+
https://cloud.google.com/assured-workloads/key-access-justifications/docs/justification-codes
74+
for the detailed semantic meaning of justification reason codes.
75+
76+
Values:
77+
REASON_UNSPECIFIED (0):
78+
Unspecified access reason.
79+
CUSTOMER_INITIATED_SUPPORT (1):
80+
Customer-initiated support.
81+
GOOGLE_INITIATED_SERVICE (2):
82+
Google-initiated access for system management
83+
and troubleshooting.
84+
THIRD_PARTY_DATA_REQUEST (3):
85+
Google-initiated access in response to a
86+
legal request or legal process.
87+
GOOGLE_INITIATED_REVIEW (4):
88+
Google-initiated access for security, fraud,
89+
abuse, or compliance purposes.
90+
CUSTOMER_INITIATED_ACCESS (5):
91+
Customer uses their account to perform any
92+
access to their own data which their IAM policy
93+
authorizes.
94+
GOOGLE_INITIATED_SYSTEM_OPERATION (6):
95+
Google systems access customer data to help
96+
optimize the structure of the data or quality
97+
for future uses by the customer.
98+
REASON_NOT_EXPECTED (7):
99+
No reason is expected for this key request.
100+
MODIFIED_CUSTOMER_INITIATED_ACCESS (8):
101+
Customer uses their account to perform any access to their
102+
own data which their IAM policy authorizes, and one of the
103+
following is true:
104+
105+
- A Google administrator has reset the root-access account
106+
associated with the user's organization within the past 7
107+
days.
108+
- A Google-initiated emergency access operation has
109+
interacted with a resource in the same project or folder
110+
as the currently accessed resource within the past 7
111+
days.
112+
MODIFIED_GOOGLE_INITIATED_SYSTEM_OPERATION (9):
113+
Google systems access customer data to help optimize the
114+
structure of the data or quality for future uses by the
115+
customer, and one of the following is true:
116+
117+
- A Google administrator has reset the root-access account
118+
associated with the user's organization within the past 7
119+
days.
120+
- A Google-initiated emergency access operation has
121+
interacted with a resource in the same project or folder
122+
as the currently accessed resource within the past 7
123+
days.
124+
GOOGLE_RESPONSE_TO_PRODUCTION_ALERT (10):
125+
Google-initiated access to maintain system
126+
reliability.
127+
CUSTOMER_AUTHORIZED_WORKFLOW_SERVICING (11):
128+
One of the following operations is being executed while
129+
simultaneously encountering an internal technical issue
130+
which prevented a more precise justification code from being
131+
generated:
132+
133+
- Your account has been used to perform any access to your
134+
own data which your IAM policy authorizes.
135+
- An automated Google system operates on encrypted customer
136+
data which your IAM policy authorizes.
137+
- Customer-initiated Google support access.
138+
- Google-initiated support access to protect system
139+
reliability.
140+
"""
141+
REASON_UNSPECIFIED = 0
142+
CUSTOMER_INITIATED_SUPPORT = 1
143+
GOOGLE_INITIATED_SERVICE = 2
144+
THIRD_PARTY_DATA_REQUEST = 3
145+
GOOGLE_INITIATED_REVIEW = 4
146+
CUSTOMER_INITIATED_ACCESS = 5
147+
GOOGLE_INITIATED_SYSTEM_OPERATION = 6
148+
REASON_NOT_EXPECTED = 7
149+
MODIFIED_CUSTOMER_INITIATED_ACCESS = 8
150+
MODIFIED_GOOGLE_INITIATED_SYSTEM_OPERATION = 9
151+
GOOGLE_RESPONSE_TO_PRODUCTION_ALERT = 10
152+
CUSTOMER_AUTHORIZED_WORKFLOW_SERVICING = 11
153+
154+
69155
class KeyRing(proto.Message):
70156
r"""A [KeyRing][google.cloud.kms.v1.KeyRing] is a toplevel logical
71157
grouping of [CryptoKeys][google.cloud.kms.v1.CryptoKey].
@@ -208,6 +294,19 @@ class CryptoKey(proto.Message):
208294
is non-exhaustive and may apply to additional
209295
[ProtectionLevels][google.cloud.kms.v1.ProtectionLevel] in
210296
the future.
297+
key_access_justifications_policy (google.cloud.kms_v1.types.KeyAccessJustificationsPolicy):
298+
Optional. The policy used for Key Access
299+
Justifications Policy Enforcement. If this field
300+
is present and this key is enrolled in Key
301+
Access Justifications Policy Enforcement, the
302+
policy will be evaluated in encrypt, decrypt,
303+
and sign operations, and the operation will fail
304+
if rejected by the policy. The policy is defined
305+
by specifying zero or more allowed justification
306+
codes.
307+
https://cloud.google.com/assured-workloads/key-access-justifications/docs/justification-codes
308+
By default, this field is absent, and all
309+
justification codes are allowed.
211310
"""
212311

213312
class CryptoKeyPurpose(proto.Enum):
@@ -313,6 +412,11 @@ class CryptoKeyPurpose(proto.Enum):
313412
proto.STRING,
314413
number=15,
315414
)
415+
key_access_justifications_policy: "KeyAccessJustificationsPolicy" = proto.Field(
416+
proto.MESSAGE,
417+
number=17,
418+
message="KeyAccessJustificationsPolicy",
419+
)
316420

317421

318422
class CryptoKeyVersionTemplate(proto.Message):
@@ -1251,4 +1355,29 @@ class ExternalProtectionLevelOptions(proto.Message):
12511355
)
12521356

12531357

1358+
class KeyAccessJustificationsPolicy(proto.Message):
1359+
r"""A
1360+
[KeyAccessJustificationsPolicy][google.cloud.kms.v1.KeyAccessJustificationsPolicy]
1361+
specifies zero or more allowed
1362+
[AccessReason][google.cloud.kms.v1.AccessReason] values for encrypt,
1363+
decrypt, and sign operations on a
1364+
[CryptoKey][google.cloud.kms.v1.CryptoKey].
1365+
1366+
Attributes:
1367+
allowed_access_reasons (MutableSequence[google.cloud.kms_v1.types.AccessReason]):
1368+
The list of allowed reasons for access to a
1369+
[CryptoKey][google.cloud.kms.v1.CryptoKey]. Zero allowed
1370+
access reasons means all encrypt, decrypt, and sign
1371+
operations for the
1372+
[CryptoKey][google.cloud.kms.v1.CryptoKey] associated with
1373+
this policy will fail.
1374+
"""
1375+
1376+
allowed_access_reasons: MutableSequence["AccessReason"] = proto.RepeatedField(
1377+
proto.ENUM,
1378+
number=1,
1379+
enum="AccessReason",
1380+
)
1381+
1382+
12541383
__all__ = tuple(sorted(__protobuf__.manifest))

packages/google-cloud-kms/tests/unit/gapic/kms_v1/test_key_management_service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16725,6 +16725,7 @@ def test_create_crypto_key_rest(request_type):
1672516725
"import_only": True,
1672616726
"destroy_scheduled_duration": {},
1672716727
"crypto_key_backend": "crypto_key_backend_value",
16728+
"key_access_justifications_policy": {"allowed_access_reasons": [1]},
1672816729
}
1672916730
# The version of a generated dependency at test runtime may differ from the version used during generation.
1673016731
# Delete any fields which are not present in the current runtime dependency
@@ -18371,6 +18372,7 @@ def test_update_crypto_key_rest(request_type):
1837118372
"import_only": True,
1837218373
"destroy_scheduled_duration": {},
1837318374
"crypto_key_backend": "crypto_key_backend_value",
18375+
"key_access_justifications_policy": {"allowed_access_reasons": [1]},
1837418376
}
1837518377
# The version of a generated dependency at test runtime may differ from the version used during generation.
1837618378
# Delete any fields which are not present in the current runtime dependency

0 commit comments

Comments
 (0)