kiarina-lib-google-auth 1.6.1__py3-none-any.whl → 1.6.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,7 @@ def get_credentials(
19
19
  cache: CredentialsCache | None = None,
20
20
  ) -> Credentials:
21
21
  if settings is None:
22
- settings = settings_manager.get_settings_by_key(config_key)
22
+ settings = settings_manager.get_settings(config_key)
23
23
 
24
24
  credentials: Credentials
25
25
 
@@ -12,6 +12,34 @@ class GoogleAuthSettings(BaseSettings):
12
12
 
13
13
  type: Literal["default", "service_account", "user_account"] = "default"
14
14
 
15
+ # --------------------------------------------------
16
+ # Fields (common)
17
+ # --------------------------------------------------
18
+
19
+ project_id: str | None = None
20
+
21
+ impersonate_service_account: str | None = None
22
+ """
23
+ Email address of the service account to impersonate
24
+
25
+ The source principal requires the roles/iam.serviceAccountTokenCreator role.
26
+ Note that this required permission is not included in the roles/owner role.
27
+ """
28
+
29
+ scopes: list[str] = Field(
30
+ default_factory=lambda: [
31
+ "https://www.googleapis.com/auth/cloud-platform", # All GCP resources
32
+ "https://www.googleapis.com/auth/drive", # Google Drive resources
33
+ "https://www.googleapis.com/auth/spreadsheets", # Google Sheets resources
34
+ ]
35
+ )
36
+ """
37
+ List of scopes to request during the authentication
38
+
39
+ Specify the scopes required for impersonation authentication.
40
+ Specify the scopes required for user account authentication.
41
+ """
42
+
15
43
  # --------------------------------------------------
16
44
  # Fields (service_account)
17
45
  # --------------------------------------------------
@@ -48,34 +76,6 @@ class GoogleAuthSettings(BaseSettings):
48
76
  Refreshed credentials will be cached.
49
77
  """
50
78
 
51
- # --------------------------------------------------
52
- # Fields (common)
53
- # --------------------------------------------------
54
-
55
- impersonate_service_account: str | None = None
56
- """
57
- Email address of the service account to impersonate
58
-
59
- The source principal requires the roles/iam.serviceAccountTokenCreator role.
60
- Note that this required permission is not included in the roles/owner role.
61
- """
62
-
63
- scopes: list[str] = Field(
64
- default_factory=lambda: [
65
- "https://www.googleapis.com/auth/cloud-platform", # All GCP resources
66
- "https://www.googleapis.com/auth/drive", # Google Drive resources
67
- "https://www.googleapis.com/auth/spreadsheets", # Google Sheets resources
68
- ]
69
- )
70
- """
71
- List of scopes to request during the authentication
72
-
73
- Specify the scopes required for impersonation authentication.
74
- Specify the scopes required for user account authentication.
75
- """
76
-
77
- project_id: str | None = None
78
-
79
79
  # --------------------------------------------------
80
80
  # Validators
81
81
  # --------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kiarina-lib-google-auth
3
- Version: 1.6.1
3
+ Version: 1.6.3
4
4
  Summary: Google Cloud client library for kiarina namespace
5
5
  Project-URL: Homepage, https://github.com/kiarina/kiarina-python
6
6
  Project-URL: Repository, https://github.com/kiarina/kiarina-python
@@ -21,7 +21,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
21
  Classifier: Typing :: Typed
22
22
  Requires-Python: >=3.12
23
23
  Requires-Dist: google-api-python-client>=2.184.0
24
- Requires-Dist: pydantic-settings-manager>=2.1.0
24
+ Requires-Dist: pydantic-settings-manager>=2.3.0
25
25
  Requires-Dist: pydantic-settings>=2.10.1
26
26
  Description-Content-Type: text/markdown
27
27
 
@@ -461,26 +461,53 @@ mise run package:test kiarina-lib-google-auth --coverage
461
461
 
462
462
  ### Test Configuration
463
463
 
464
- Some tests require actual GCP credentials. Set the following environment variables:
464
+ Some tests require actual GCP credentials. Create a test settings file and set the environment variable to point to it:
465
465
 
466
466
  ```bash
467
- # Service account key file
468
- export KIARINA_LIB_GOOGLE_AUTH_TEST_GCP_SA_KEY_FILE="~/path/to/sa-key.json"
467
+ # Create test settings file from sample
468
+ cp packages/kiarina-lib-google-auth/test_settings.sample.yaml \
469
+ packages/kiarina-lib-google-auth/test_settings.yaml
469
470
 
470
- # Service account key data (JSON string)
471
- export KIARINA_LIB_GOOGLE_AUTH_TEST_GCP_SA_KEY_DATA='{"type": "service_account", ...}'
472
-
473
- # Authorized user file
474
- export KIARINA_LIB_GOOGLE_AUTH_TEST_GCP_AUTHORIZED_USER_FILE="~/.config/gcloud/application_default_credentials.json"
475
-
476
- # Authorized user data (JSON string)
477
- export KIARINA_LIB_GOOGLE_AUTH_TEST_GCP_AUTHORIZED_USER_DATA='{"type": "authorized_user", ...}'
471
+ # Edit the file with your actual credentials
472
+ # Then set the environment variable
473
+ export KIARINA_LIB_GOOGLE_AUTH_TEST_SETTINGS_FILE="packages/kiarina-lib-google-auth/test_settings.yaml"
474
+ ```
478
475
 
479
- # Target service account for impersonation tests
480
- export KIARINA_LIB_GOOGLE_AUTH_TEST_GCP_IMPERSONATE_SA="target-sa@project.iam.gserviceaccount.com"
476
+ The test settings file should contain multiple named configurations for different authentication scenarios:
477
+
478
+ ```yaml
479
+ kiarina.lib.google.auth:
480
+ default:
481
+ type: default
482
+ service_account_file:
483
+ type: service_account
484
+ project_id: your-project-id
485
+ service_account_email: your-service-account@your-project.iam.gserviceaccount.com
486
+ service_account_file: ~/.gcp/service-account/your-project/your-service-account/key.json
487
+ service_account_data:
488
+ type: service_account
489
+ project_id: your-project-id
490
+ service_account_email: your-service-account@your-project.iam.gserviceaccount.com
491
+ service_account_data: '{"type":"service_account","project_id":"...","private_key":"...","client_email":"..."}'
492
+ service_account_impersonate:
493
+ type: service_account
494
+ project_id: your-project-id
495
+ service_account_email: your-service-account@your-project.iam.gserviceaccount.com
496
+ service_account_file: ~/.gcp/service-account/your-project/your-service-account/key.json
497
+ impersonate_service_account: impersonated-account@your-project.iam.gserviceaccount.com
498
+ user_account_file:
499
+ type: user_account
500
+ project_id: your-project-id
501
+ user_account_email: your-email@example.com
502
+ authorized_user_file: ~/.gcp/oauth2/your-project/authorized_user.json
503
+ user_account_data:
504
+ type: user_account
505
+ project_id: your-project-id
506
+ user_account_email: your-email@example.com
507
+ authorized_user_data: '{"type":"authorized_user","client_id":"...","client_secret":"...","refresh_token":"..."}'
481
508
  ```
482
509
 
483
- Tests will be skipped (xfail) if these environment variables are not set.
510
+ **Note**: The `test_settings.yaml` file is gitignored to prevent accidental credential exposure.
484
511
 
485
512
  ## Dependencies
486
513
 
@@ -1,8 +1,8 @@
1
1
  kiarina/lib/google/auth/__init__.py,sha256=SdD3zDQ0MebC3qbtyjpZx3HZeUL5G-4fQ3mtqQT32us,2014
2
2
  kiarina/lib/google/auth/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- kiarina/lib/google/auth/settings.py,sha256=kaOFOLl7xGQ6jOiBSjUZWLdWzj_Gic-lOAKZEE6yasg,3803
3
+ kiarina/lib/google/auth/settings.py,sha256=npwaCRkyuHJwrhRANdnq1stgowDMHplpQJPqGvx-DoE,3803
4
4
  kiarina/lib/google/auth/_helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- kiarina/lib/google/auth/_helpers/get_credentials.py,sha256=htDgNumKBwX3b11LHjRjSR-Ciou3NBWek8f7-caPy1g,2298
5
+ kiarina/lib/google/auth/_helpers/get_credentials.py,sha256=RWTqvH1hhh1dl3R6XE71swal2t-KduHdEhGBFBVN6hY,2291
6
6
  kiarina/lib/google/auth/_helpers/get_self_signed_jwt.py,sha256=rAFZXBk-xM5YNCiwi9bJzY4CxpR96NRUMJbCJ8bdH4k,756
7
7
  kiarina/lib/google/auth/_types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  kiarina/lib/google/auth/_types/credentials.py,sha256=8gjsjUydlbhW56JHfMHymbeoej5zp8ZopMQ2dYSvT70,415
@@ -11,6 +11,6 @@ kiarina/lib/google/auth/_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
11
11
  kiarina/lib/google/auth/_utils/get_default_credentials.py,sha256=2mkQ4eWM-lpM-1L7aprw9O2U3ZB-DE75cmpYj6d2fQs,1230
12
12
  kiarina/lib/google/auth/_utils/get_service_account_credentials.py,sha256=XGV8VRTHB9fNLKN9q66cV27lBPDExYG0UUag8mU3mEg,945
13
13
  kiarina/lib/google/auth/_utils/get_user_account_credentials.py,sha256=ihko1Xf_e5EkZ1c5CjAYl8NOvjj6dKtvHl8TH_oLbTU,2353
14
- kiarina_lib_google_auth-1.6.1.dist-info/METADATA,sha256=96y84W1ItARy6vn7EA7mUFhsSRJtjzeyphxclkwyNOE,15973
15
- kiarina_lib_google_auth-1.6.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- kiarina_lib_google_auth-1.6.1.dist-info/RECORD,,
14
+ kiarina_lib_google_auth-1.6.3.dist-info/METADATA,sha256=uobseVUVBX_xCwjo6Z9_1Je4G2mZ-gfI-PbPpRkpVqI,17232
15
+ kiarina_lib_google_auth-1.6.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ kiarina_lib_google_auth-1.6.3.dist-info/RECORD,,