pangea-sdk 3.8.0b4__py3-none-any.whl → 4.0.0__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.
- pangea/__init__.py +1 -2
- pangea/asyncio/request.py +17 -22
- pangea/asyncio/services/__init__.py +0 -2
- pangea/asyncio/services/audit.py +188 -23
- pangea/asyncio/services/authn.py +167 -108
- pangea/asyncio/services/authz.py +36 -45
- pangea/asyncio/services/embargo.py +2 -2
- pangea/asyncio/services/file_scan.py +3 -3
- pangea/asyncio/services/intel.py +44 -26
- pangea/asyncio/services/redact.py +60 -4
- pangea/asyncio/services/vault.py +145 -30
- pangea/dump_audit.py +1 -1
- pangea/request.py +30 -24
- pangea/response.py +34 -42
- pangea/services/__init__.py +0 -2
- pangea/services/audit/audit.py +202 -34
- pangea/services/audit/models.py +56 -8
- pangea/services/audit/util.py +3 -3
- pangea/services/authn/authn.py +116 -65
- pangea/services/authn/models.py +88 -4
- pangea/services/authz.py +51 -56
- pangea/services/base.py +23 -6
- pangea/services/embargo.py +2 -2
- pangea/services/file_scan.py +3 -2
- pangea/services/intel.py +25 -23
- pangea/services/redact.py +124 -4
- pangea/services/vault/models/common.py +121 -6
- pangea/services/vault/models/symmetric.py +2 -2
- pangea/services/vault/vault.py +143 -32
- pangea/utils.py +20 -109
- pangea/verify_audit.py +267 -83
- {pangea_sdk-3.8.0b4.dist-info → pangea_sdk-4.0.0.dist-info}/METADATA +12 -20
- pangea_sdk-4.0.0.dist-info/RECORD +46 -0
- {pangea_sdk-3.8.0b4.dist-info → pangea_sdk-4.0.0.dist-info}/WHEEL +1 -1
- pangea/asyncio/__init__.py +0 -1
- pangea/asyncio/file_uploader.py +0 -39
- pangea/asyncio/services/sanitize.py +0 -185
- pangea/asyncio/services/share.py +0 -573
- pangea/file_uploader.py +0 -35
- pangea/services/sanitize.py +0 -275
- pangea/services/share/file_format.py +0 -170
- pangea/services/share/share.py +0 -877
- pangea_sdk-3.8.0b4.dist-info/RECORD +0 -54
pangea/services/authn/authn.py
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
from __future__ import annotations
|
3
4
|
|
4
5
|
from typing import Dict, List, Optional, Union
|
5
6
|
|
6
7
|
import pangea.services.authn.models as m
|
8
|
+
from pangea.config import PangeaConfig
|
7
9
|
from pangea.response import PangeaResponse
|
8
10
|
from pangea.services.base import ServiceBase
|
9
11
|
|
@@ -37,10 +39,24 @@ class AuthN(ServiceBase):
|
|
37
39
|
|
38
40
|
def __init__(
|
39
41
|
self,
|
40
|
-
token,
|
41
|
-
config=None,
|
42
|
-
logger_name="pangea",
|
43
|
-
):
|
42
|
+
token: str,
|
43
|
+
config: PangeaConfig | None = None,
|
44
|
+
logger_name: str = "pangea",
|
45
|
+
) -> None:
|
46
|
+
"""
|
47
|
+
AuthN client
|
48
|
+
|
49
|
+
Initializes a new AuthN client.
|
50
|
+
|
51
|
+
Args:
|
52
|
+
token: Pangea API token.
|
53
|
+
config: Configuration.
|
54
|
+
logger_name: Logger name.
|
55
|
+
|
56
|
+
Examples:
|
57
|
+
config = PangeaConfig(domain="pangea_domain")
|
58
|
+
authn = AuthN(token="pangea_token", config=config)
|
59
|
+
"""
|
44
60
|
super().__init__(token, config, logger_name=logger_name)
|
45
61
|
self.user = AuthN.User(token, config, logger_name=logger_name)
|
46
62
|
self.flow = AuthN.Flow(token, config, logger_name=logger_name)
|
@@ -80,7 +96,7 @@ class AuthN(ServiceBase):
|
|
80
96
|
"""
|
81
97
|
input = m.SessionInvalidateRequest(session_id=session_id)
|
82
98
|
return self.request.post(
|
83
|
-
"v2/session/invalidate", m.SessionInvalidateResult, data=input.
|
99
|
+
"v2/session/invalidate", m.SessionInvalidateResult, data=input.model_dump(exclude_none=True)
|
84
100
|
)
|
85
101
|
|
86
102
|
def list(
|
@@ -118,7 +134,7 @@ class AuthN(ServiceBase):
|
|
118
134
|
filter = m.SessionListFilter(**filter)
|
119
135
|
|
120
136
|
input = m.SessionListRequest(filter=filter, last=last, order=order, order_by=order_by, size=size)
|
121
|
-
return self.request.post("v2/session/list", m.SessionListResults, data=input.
|
137
|
+
return self.request.post("v2/session/list", m.SessionListResults, data=input.model_dump(exclude_none=True))
|
122
138
|
|
123
139
|
def logout(self, user_id: str) -> PangeaResponse[m.SessionLogoutResult]:
|
124
140
|
"""
|
@@ -140,7 +156,9 @@ class AuthN(ServiceBase):
|
|
140
156
|
)
|
141
157
|
"""
|
142
158
|
input = m.SessionLogoutRequest(user_id=user_id)
|
143
|
-
return self.request.post(
|
159
|
+
return self.request.post(
|
160
|
+
"v2/session/logout", m.SessionLogoutResult, data=input.model_dump(exclude_none=True)
|
161
|
+
)
|
144
162
|
|
145
163
|
class Client(ServiceBase):
|
146
164
|
service_name = SERVICE_NAME
|
@@ -178,7 +196,9 @@ class AuthN(ServiceBase):
|
|
178
196
|
)
|
179
197
|
"""
|
180
198
|
input = m.ClientUserinfoRequest(code=code)
|
181
|
-
return self.request.post(
|
199
|
+
return self.request.post(
|
200
|
+
"v2/client/userinfo", m.ClientUserinfoResult, data=input.model_dump(exclude_none=True)
|
201
|
+
)
|
182
202
|
|
183
203
|
def jwks(
|
184
204
|
self,
|
@@ -234,7 +254,9 @@ class AuthN(ServiceBase):
|
|
234
254
|
"""
|
235
255
|
input = m.ClientSessionInvalidateRequest(token=token, session_id=session_id)
|
236
256
|
return self.request.post(
|
237
|
-
"v2/client/session/invalidate",
|
257
|
+
"v2/client/session/invalidate",
|
258
|
+
m.ClientSessionInvalidateResult,
|
259
|
+
data=input.model_dump(exclude_none=True),
|
238
260
|
)
|
239
261
|
|
240
262
|
def list(
|
@@ -279,7 +301,7 @@ class AuthN(ServiceBase):
|
|
279
301
|
token=token, filter=filter, last=last, order=order, order_by=order_by, size=size
|
280
302
|
)
|
281
303
|
return self.request.post(
|
282
|
-
"v2/client/session/list", m.ClientSessionListResults, data=input.
|
304
|
+
"v2/client/session/list", m.ClientSessionListResults, data=input.model_dump(exclude_none=True)
|
283
305
|
)
|
284
306
|
|
285
307
|
def logout(self, token: str) -> PangeaResponse[m.ClientSessionLogoutResult]:
|
@@ -303,7 +325,7 @@ class AuthN(ServiceBase):
|
|
303
325
|
"""
|
304
326
|
input = m.ClientSessionLogoutRequest(token=token)
|
305
327
|
return self.request.post(
|
306
|
-
"v2/client/session/logout", m.ClientSessionLogoutResult, data=input.
|
328
|
+
"v2/client/session/logout", m.ClientSessionLogoutResult, data=input.model_dump(exclude_none=True)
|
307
329
|
)
|
308
330
|
|
309
331
|
def refresh(
|
@@ -333,7 +355,7 @@ class AuthN(ServiceBase):
|
|
333
355
|
"""
|
334
356
|
input = m.ClientSessionRefreshRequest(refresh_token=refresh_token, user_token=user_token)
|
335
357
|
return self.request.post(
|
336
|
-
"v2/client/session/refresh", m.ClientSessionRefreshResult, data=input.
|
358
|
+
"v2/client/session/refresh", m.ClientSessionRefreshResult, data=input.model_dump(exclude_none=True)
|
337
359
|
)
|
338
360
|
|
339
361
|
class Password(ServiceBase):
|
@@ -374,7 +396,7 @@ class AuthN(ServiceBase):
|
|
374
396
|
"""
|
375
397
|
input = m.ClientPasswordChangeRequest(token=token, old_password=old_password, new_password=new_password)
|
376
398
|
return self.request.post(
|
377
|
-
"v2/client/password/change", m.ClientPasswordChangeResult, data=input.
|
399
|
+
"v2/client/password/change", m.ClientPasswordChangeResult, data=input.model_dump(exclude_none=True)
|
378
400
|
)
|
379
401
|
|
380
402
|
class Token(ServiceBase):
|
@@ -411,7 +433,7 @@ class AuthN(ServiceBase):
|
|
411
433
|
"""
|
412
434
|
input = m.ClientTokenCheckRequest(token=token)
|
413
435
|
return self.request.post(
|
414
|
-
"v2/client/token/check", m.ClientTokenCheckResult, data=input.
|
436
|
+
"v2/client/token/check", m.ClientTokenCheckResult, data=input.model_dump(exclude_none=True)
|
415
437
|
)
|
416
438
|
|
417
439
|
class User(ServiceBase):
|
@@ -432,6 +454,8 @@ class AuthN(ServiceBase):
|
|
432
454
|
self,
|
433
455
|
email: str,
|
434
456
|
profile: m.Profile,
|
457
|
+
*,
|
458
|
+
username: str | None = None,
|
435
459
|
) -> PangeaResponse[m.UserCreateResult]:
|
436
460
|
"""
|
437
461
|
Create User
|
@@ -441,8 +465,9 @@ class AuthN(ServiceBase):
|
|
441
465
|
OperationId: authn_post_v2_user_create
|
442
466
|
|
443
467
|
Args:
|
444
|
-
email
|
445
|
-
profile
|
468
|
+
email: An email address.
|
469
|
+
profile: A user profile as a collection of string properties.
|
470
|
+
username: A username.
|
446
471
|
|
447
472
|
Returns:
|
448
473
|
A PangeaResponse with a user and its information in the response.result field.
|
@@ -461,10 +486,13 @@ class AuthN(ServiceBase):
|
|
461
486
|
input = m.UserCreateRequest(
|
462
487
|
email=email,
|
463
488
|
profile=profile,
|
489
|
+
username=username,
|
464
490
|
)
|
465
|
-
return self.request.post("v2/user/create", m.UserCreateResult, data=input.
|
491
|
+
return self.request.post("v2/user/create", m.UserCreateResult, data=input.model_dump(exclude_none=True))
|
466
492
|
|
467
|
-
def delete(
|
493
|
+
def delete(
|
494
|
+
self, email: str | None = None, id: str | None = None, *, username: str | None = None
|
495
|
+
) -> PangeaResponse[m.UserDeleteResult]:
|
468
496
|
"""
|
469
497
|
Delete User
|
470
498
|
|
@@ -473,8 +501,9 @@ class AuthN(ServiceBase):
|
|
473
501
|
OperationId: authn_post_v2_user_delete
|
474
502
|
|
475
503
|
Args:
|
476
|
-
email
|
477
|
-
id
|
504
|
+
email: An email address.
|
505
|
+
id: The id of a user or a service.
|
506
|
+
username: A username.
|
478
507
|
|
479
508
|
Returns:
|
480
509
|
A PangeaResponse with an empty object in the response.result field.
|
@@ -482,8 +511,8 @@ class AuthN(ServiceBase):
|
|
482
511
|
Examples:
|
483
512
|
authn.user.delete(email="example@example.com")
|
484
513
|
"""
|
485
|
-
input = m.UserDeleteRequest(email=email, id=id)
|
486
|
-
return self.request.post("v2/user/delete", m.UserDeleteResult, data=input.
|
514
|
+
input = m.UserDeleteRequest(email=email, id=id, username=username)
|
515
|
+
return self.request.post("v2/user/delete", m.UserDeleteResult, data=input.model_dump(exclude_none=True))
|
487
516
|
|
488
517
|
def invite(
|
489
518
|
self,
|
@@ -524,14 +553,16 @@ class AuthN(ServiceBase):
|
|
524
553
|
callback=callback,
|
525
554
|
state=state,
|
526
555
|
)
|
527
|
-
return self.request.post("v2/user/invite", m.UserInviteResult, data=input.
|
556
|
+
return self.request.post("v2/user/invite", m.UserInviteResult, data=input.model_dump(exclude_none=True))
|
528
557
|
|
529
558
|
def update(
|
530
559
|
self,
|
531
|
-
disabled:
|
532
|
-
id:
|
533
|
-
email:
|
534
|
-
unlock:
|
560
|
+
disabled: bool | None = None,
|
561
|
+
id: str | None = None,
|
562
|
+
email: str | None = None,
|
563
|
+
unlock: bool | None = None,
|
564
|
+
*,
|
565
|
+
username: str | None = None,
|
535
566
|
) -> PangeaResponse[m.UserUpdateResult]:
|
536
567
|
"""
|
537
568
|
Update user's settings
|
@@ -541,11 +572,12 @@ class AuthN(ServiceBase):
|
|
541
572
|
OperationId: authn_post_v2_user_update
|
542
573
|
|
543
574
|
Args:
|
544
|
-
disabled
|
575
|
+
disabled: New disabled value.
|
545
576
|
Disabling a user account will prevent them from logging in.
|
546
|
-
unlock
|
547
|
-
id
|
548
|
-
email
|
577
|
+
unlock: Unlock a user account if it has been locked out due to failed authentication attempts.
|
578
|
+
id: The identity of a user or a service.
|
579
|
+
email: An email address.
|
580
|
+
username: A username.
|
549
581
|
|
550
582
|
Returns:
|
551
583
|
A PangeaResponse with a user and its information in the response.result field.
|
@@ -563,9 +595,10 @@ class AuthN(ServiceBase):
|
|
563
595
|
email=email,
|
564
596
|
disabled=disabled,
|
565
597
|
unlock=unlock,
|
598
|
+
username=username,
|
566
599
|
)
|
567
600
|
|
568
|
-
return self.request.post("v2/user/update", m.UserUpdateResult, data=input.
|
601
|
+
return self.request.post("v2/user/update", m.UserUpdateResult, data=input.model_dump(exclude_none=True))
|
569
602
|
|
570
603
|
def list(
|
571
604
|
self,
|
@@ -608,7 +641,7 @@ class AuthN(ServiceBase):
|
|
608
641
|
order_by=order_by,
|
609
642
|
size=size,
|
610
643
|
)
|
611
|
-
return self.request.post("v2/user/list", m.UserListResult, data=input.
|
644
|
+
return self.request.post("v2/user/list", m.UserListResult, data=input.model_dump(exclude_none=True))
|
612
645
|
|
613
646
|
class Invites(ServiceBase):
|
614
647
|
service_name = SERVICE_NAME
|
@@ -655,7 +688,7 @@ class AuthN(ServiceBase):
|
|
655
688
|
|
656
689
|
input = m.UserInviteListRequest(filter=filter, last=last, order=order, order_by=order_by, size=size)
|
657
690
|
return self.request.post(
|
658
|
-
"v2/user/invite/list", m.UserInviteListResult, data=input.
|
691
|
+
"v2/user/invite/list", m.UserInviteListResult, data=input.model_dump(exclude_none=True)
|
659
692
|
)
|
660
693
|
|
661
694
|
def delete(self, id: str) -> PangeaResponse[m.UserInviteDeleteResult]:
|
@@ -679,7 +712,7 @@ class AuthN(ServiceBase):
|
|
679
712
|
"""
|
680
713
|
input = m.UserInviteDeleteRequest(id=id)
|
681
714
|
return self.request.post(
|
682
|
-
"v2/user/invite/delete", m.UserInviteDeleteResult, data=input.
|
715
|
+
"v2/user/invite/delete", m.UserInviteDeleteResult, data=input.model_dump(exclude_none=True)
|
683
716
|
)
|
684
717
|
|
685
718
|
class Authenticators(ServiceBase):
|
@@ -694,7 +727,12 @@ class AuthN(ServiceBase):
|
|
694
727
|
super().__init__(token, config, logger_name=logger_name)
|
695
728
|
|
696
729
|
def delete(
|
697
|
-
self,
|
730
|
+
self,
|
731
|
+
authenticator_id: str,
|
732
|
+
id: str | None = None,
|
733
|
+
email: str | None = None,
|
734
|
+
*,
|
735
|
+
username: str | None = None,
|
698
736
|
) -> PangeaResponse[m.UserAuthenticatorsDeleteResult]:
|
699
737
|
"""
|
700
738
|
Delete user authenticator
|
@@ -704,9 +742,10 @@ class AuthN(ServiceBase):
|
|
704
742
|
OperationId: authn_post_v2_user_authenticators_delete
|
705
743
|
|
706
744
|
Args:
|
707
|
-
authenticator_id
|
708
|
-
id
|
709
|
-
email
|
745
|
+
authenticator_id: An ID for an authenticator.
|
746
|
+
id: The identity of a user or a service.
|
747
|
+
email: An email address.
|
748
|
+
username: A username.
|
710
749
|
|
711
750
|
Returns:
|
712
751
|
A PangeaResponse with an empty object in the response.result field.
|
@@ -717,15 +756,17 @@ class AuthN(ServiceBase):
|
|
717
756
|
id="pui_xpkhwpnz2cmegsws737xbsqnmnuwtbm5",
|
718
757
|
)
|
719
758
|
"""
|
720
|
-
input = m.UserAuthenticatorsDeleteRequest(
|
759
|
+
input = m.UserAuthenticatorsDeleteRequest(
|
760
|
+
authenticator_id=authenticator_id, email=email, id=id, username=username
|
761
|
+
)
|
721
762
|
return self.request.post(
|
722
763
|
"v2/user/authenticators/delete",
|
723
764
|
m.UserAuthenticatorsDeleteResult,
|
724
|
-
data=input.
|
765
|
+
data=input.model_dump(exclude_none=True),
|
725
766
|
)
|
726
767
|
|
727
768
|
def list(
|
728
|
-
self, email:
|
769
|
+
self, email: str | None = None, id: str | None = None, *, username: str | None = None
|
729
770
|
) -> PangeaResponse[m.UserAuthenticatorsListResult]:
|
730
771
|
"""
|
731
772
|
Get user authenticators
|
@@ -735,8 +776,9 @@ class AuthN(ServiceBase):
|
|
735
776
|
OperationId: authn_post_v2_user_authenticators_list
|
736
777
|
|
737
778
|
Args:
|
738
|
-
email
|
739
|
-
id
|
779
|
+
email: An email address.
|
780
|
+
id: The identity of a user or a service.
|
781
|
+
username: A username.
|
740
782
|
|
741
783
|
Returns:
|
742
784
|
A PangeaResponse with a list of authenticators in the response.result field.
|
@@ -748,9 +790,11 @@ class AuthN(ServiceBase):
|
|
748
790
|
id="pui_xpkhwpnz2cmegsws737xbsqnmnuwtbm5",
|
749
791
|
)
|
750
792
|
"""
|
751
|
-
input = m.UserAuthenticatorsListRequest(email=email, id=id)
|
793
|
+
input = m.UserAuthenticatorsListRequest(email=email, id=id, username=username)
|
752
794
|
return self.request.post(
|
753
|
-
"v2/user/authenticators/list",
|
795
|
+
"v2/user/authenticators/list",
|
796
|
+
m.UserAuthenticatorsListResult,
|
797
|
+
data=input.model_dump(exclude_none=True),
|
754
798
|
)
|
755
799
|
|
756
800
|
class Profile(ServiceBase):
|
@@ -765,7 +809,7 @@ class AuthN(ServiceBase):
|
|
765
809
|
super().__init__(token, config, logger_name=logger_name)
|
766
810
|
|
767
811
|
def get(
|
768
|
-
self, id:
|
812
|
+
self, id: str | None = None, email: str | None = None, *, username: str | None = None
|
769
813
|
) -> PangeaResponse[m.UserProfileGetResult]:
|
770
814
|
"""
|
771
815
|
Get user
|
@@ -775,8 +819,9 @@ class AuthN(ServiceBase):
|
|
775
819
|
OperationId: authn_post_v2_user_profile_get
|
776
820
|
|
777
821
|
Args:
|
778
|
-
id
|
779
|
-
email
|
822
|
+
id: The identity of a user or a service.
|
823
|
+
email: An email address.
|
824
|
+
username: A username.
|
780
825
|
|
781
826
|
Returns:
|
782
827
|
A PangeaResponse with a user and its information in the response.result field.
|
@@ -788,16 +833,18 @@ class AuthN(ServiceBase):
|
|
788
833
|
email="joe.user@email.com",
|
789
834
|
)
|
790
835
|
"""
|
791
|
-
input = m.UserProfileGetRequest(id=id, email=email)
|
836
|
+
input = m.UserProfileGetRequest(id=id, email=email, username=username)
|
792
837
|
return self.request.post(
|
793
|
-
"v2/user/profile/get", m.UserProfileGetResult, data=input.
|
838
|
+
"v2/user/profile/get", m.UserProfileGetResult, data=input.model_dump(exclude_none=True)
|
794
839
|
)
|
795
840
|
|
796
841
|
def update(
|
797
842
|
self,
|
798
843
|
profile: m.Profile,
|
799
|
-
id:
|
800
|
-
email:
|
844
|
+
id: str | None = None,
|
845
|
+
email: str | None = None,
|
846
|
+
*,
|
847
|
+
username: str | None = None,
|
801
848
|
) -> PangeaResponse[m.UserProfileUpdateResult]:
|
802
849
|
"""
|
803
850
|
Update user
|
@@ -807,9 +854,10 @@ class AuthN(ServiceBase):
|
|
807
854
|
OperationId: authn_post_v2_user_profile_update
|
808
855
|
|
809
856
|
Args:
|
810
|
-
profile
|
811
|
-
id
|
812
|
-
email
|
857
|
+
profile: Updates to a user profile.
|
858
|
+
id: The identity of a user or a service.
|
859
|
+
email: An email address.
|
860
|
+
username: A username.
|
813
861
|
|
814
862
|
Returns:
|
815
863
|
A PangeaResponse with a user and its information in the response.result field.
|
@@ -828,9 +876,10 @@ class AuthN(ServiceBase):
|
|
828
876
|
id=id,
|
829
877
|
email=email,
|
830
878
|
profile=profile,
|
879
|
+
username=username,
|
831
880
|
)
|
832
881
|
return self.request.post(
|
833
|
-
"v2/user/profile/update", m.UserProfileUpdateResult, data=input.
|
882
|
+
"v2/user/profile/update", m.UserProfileUpdateResult, data=input.model_dump(exclude_none=True)
|
834
883
|
)
|
835
884
|
|
836
885
|
class Flow(ServiceBase):
|
@@ -866,7 +915,7 @@ class AuthN(ServiceBase):
|
|
866
915
|
)
|
867
916
|
"""
|
868
917
|
input = m.FlowCompleteRequest(flow_id=flow_id)
|
869
|
-
return self.request.post("v2/flow/complete", m.FlowCompleteResult, data=input.
|
918
|
+
return self.request.post("v2/flow/complete", m.FlowCompleteResult, data=input.model_dump(exclude_none=True))
|
870
919
|
|
871
920
|
def restart(
|
872
921
|
self, flow_id: str, choice: m.FlowChoice, data: m.FlowRestartData = {}
|
@@ -898,7 +947,7 @@ class AuthN(ServiceBase):
|
|
898
947
|
"""
|
899
948
|
|
900
949
|
input = m.FlowRestartRequest(flow_id=flow_id, choice=choice, data=data)
|
901
|
-
return self.request.post("v2/flow/restart", m.FlowRestartResult, data=input.
|
950
|
+
return self.request.post("v2/flow/restart", m.FlowRestartResult, data=input.model_dump(exclude_none=True))
|
902
951
|
|
903
952
|
def start(
|
904
953
|
self,
|
@@ -937,7 +986,7 @@ class AuthN(ServiceBase):
|
|
937
986
|
)
|
938
987
|
"""
|
939
988
|
input = m.FlowStartRequest(cb_uri=cb_uri, email=email, flow_types=flow_types, invitation=invitation)
|
940
|
-
return self.request.post("v2/flow/start", m.FlowStartResult, data=input.
|
989
|
+
return self.request.post("v2/flow/start", m.FlowStartResult, data=input.model_dump(exclude_none=True))
|
941
990
|
|
942
991
|
def update(
|
943
992
|
self, flow_id: str, choice: m.FlowChoice, data: m.FlowUpdateData = {}
|
@@ -971,7 +1020,7 @@ class AuthN(ServiceBase):
|
|
971
1020
|
"""
|
972
1021
|
|
973
1022
|
input = m.FlowUpdateRequest(flow_id=flow_id, choice=choice, data=data)
|
974
|
-
return self.request.post("v2/flow/update", m.FlowUpdateResult, data=input.
|
1023
|
+
return self.request.post("v2/flow/update", m.FlowUpdateResult, data=input.model_dump(exclude_none=True))
|
975
1024
|
|
976
1025
|
class Agreements(ServiceBase):
|
977
1026
|
service_name = SERVICE_NAME
|
@@ -1015,7 +1064,7 @@ class AuthN(ServiceBase):
|
|
1015
1064
|
|
1016
1065
|
input = m.AgreementCreateRequest(type=type, name=name, text=text, active=active)
|
1017
1066
|
return self.request.post(
|
1018
|
-
"v2/agreements/create", m.AgreementCreateResult, data=input.
|
1067
|
+
"v2/agreements/create", m.AgreementCreateResult, data=input.model_dump(exclude_none=True)
|
1019
1068
|
)
|
1020
1069
|
|
1021
1070
|
def delete(self, type: m.AgreementType, id: str) -> PangeaResponse[m.AgreementDeleteResult]:
|
@@ -1042,7 +1091,7 @@ class AuthN(ServiceBase):
|
|
1042
1091
|
|
1043
1092
|
input = m.AgreementDeleteRequest(type=type, id=id)
|
1044
1093
|
return self.request.post(
|
1045
|
-
"v2/agreements/delete", m.AgreementDeleteResult, data=input.
|
1094
|
+
"v2/agreements/delete", m.AgreementDeleteResult, data=input.model_dump(exclude_none=True)
|
1046
1095
|
)
|
1047
1096
|
|
1048
1097
|
def list(
|
@@ -1080,7 +1129,9 @@ class AuthN(ServiceBase):
|
|
1080
1129
|
filter = m.AgreementListFilter(**filter)
|
1081
1130
|
|
1082
1131
|
input = m.AgreementListRequest(filter=filter, last=last, order=order, order_by=order_by, size=size)
|
1083
|
-
return self.request.post(
|
1132
|
+
return self.request.post(
|
1133
|
+
"v2/agreements/list", m.AgreementListResult, data=input.model_dump(exclude_none=True)
|
1134
|
+
)
|
1084
1135
|
|
1085
1136
|
def update(
|
1086
1137
|
self,
|
@@ -1120,5 +1171,5 @@ class AuthN(ServiceBase):
|
|
1120
1171
|
|
1121
1172
|
input = m.AgreementUpdateRequest(type=type, id=id, name=name, text=text, active=active)
|
1122
1173
|
return self.request.post(
|
1123
|
-
"v2/agreements/update", m.AgreementUpdateResult, data=input.
|
1174
|
+
"v2/agreements/update", m.AgreementUpdateResult, data=input.model_dump(exclude_none=True)
|
1124
1175
|
)
|
pangea/services/authn/models.py
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
3
|
|
4
|
+
from __future__ import annotations
|
5
|
+
|
4
6
|
import enum
|
5
7
|
from typing import Dict, List, NewType, Optional, Union
|
6
8
|
|
9
|
+
from pydantic import BaseModel, ConfigDict
|
10
|
+
|
7
11
|
import pangea.services.intel as im
|
8
12
|
from pangea.response import APIRequestModel, APIResponseModel, PangeaResponseResult
|
9
13
|
from pangea.services.vault.models.common import JWK, JWKec, JWKrsa
|
@@ -11,11 +15,13 @@ from pangea.services.vault.models.common import JWK, JWKec, JWKrsa
|
|
11
15
|
Scopes = NewType("Scopes", List[str])
|
12
16
|
|
13
17
|
|
14
|
-
class Profile(
|
18
|
+
class Profile(BaseModel):
|
15
19
|
first_name: str
|
16
|
-
last_name: str
|
20
|
+
last_name: Optional[str] = None
|
17
21
|
phone: Optional[str] = None
|
18
22
|
|
23
|
+
model_config = ConfigDict(extra="allow")
|
24
|
+
|
19
25
|
|
20
26
|
class ClientPasswordChangeRequest(APIRequestModel):
|
21
27
|
token: str
|
@@ -69,7 +75,7 @@ class LoginToken(SessionToken):
|
|
69
75
|
|
70
76
|
|
71
77
|
class ClientTokenCheckResult(SessionToken):
|
72
|
-
token: Optional[str]
|
78
|
+
token: Optional[str] = None
|
73
79
|
|
74
80
|
|
75
81
|
class IDProvider(str, enum.Enum):
|
@@ -160,24 +166,52 @@ class Authenticator(APIResponseModel):
|
|
160
166
|
|
161
167
|
class User(PangeaResponseResult):
|
162
168
|
id: str
|
169
|
+
"""The identity of a user or a service."""
|
170
|
+
|
163
171
|
email: str
|
172
|
+
"""An email address."""
|
173
|
+
|
174
|
+
username: str
|
175
|
+
"""A username."""
|
176
|
+
|
164
177
|
profile: Profile
|
178
|
+
"""A user profile as a collection of string properties."""
|
179
|
+
|
165
180
|
verified: bool
|
181
|
+
"""True if the user's email has been verified."""
|
182
|
+
|
166
183
|
disabled: bool
|
184
|
+
"""True if the service administrator has disabled user account."""
|
185
|
+
|
167
186
|
accepted_eula_id: Optional[str] = None
|
187
|
+
"""An ID for an agreement."""
|
188
|
+
|
168
189
|
accepted_privacy_policy_id: Optional[str] = None
|
190
|
+
"""An ID for an agreement."""
|
191
|
+
|
169
192
|
last_login_at: Optional[str] = None
|
193
|
+
"""A time in ISO-8601 format."""
|
194
|
+
|
170
195
|
created_at: str
|
196
|
+
"""A time in ISO-8601 format."""
|
197
|
+
|
171
198
|
login_count: int = 0
|
172
199
|
last_login_ip: Optional[str] = None
|
173
200
|
last_login_city: Optional[str] = None
|
174
201
|
last_login_country: Optional[str] = None
|
175
202
|
authenticators: List[Authenticator] = []
|
203
|
+
"""A list of authenticators."""
|
176
204
|
|
177
205
|
|
178
206
|
class UserCreateRequest(APIRequestModel):
|
179
207
|
email: str
|
208
|
+
"""An email address."""
|
209
|
+
|
180
210
|
profile: Profile
|
211
|
+
"""A user profile as a collection of string properties."""
|
212
|
+
|
213
|
+
username: Optional[str] = None
|
214
|
+
"""A username."""
|
181
215
|
|
182
216
|
|
183
217
|
class UserCreateResult(User):
|
@@ -186,7 +220,13 @@ class UserCreateResult(User):
|
|
186
220
|
|
187
221
|
class UserDeleteRequest(APIRequestModel):
|
188
222
|
email: Optional[str] = None
|
223
|
+
"""An email address."""
|
224
|
+
|
189
225
|
id: Optional[str] = None
|
226
|
+
"""The identity of a user or a service."""
|
227
|
+
|
228
|
+
username: Optional[str] = None
|
229
|
+
"""A username."""
|
190
230
|
|
191
231
|
|
192
232
|
class UserDeleteResult(PangeaResponseResult):
|
@@ -289,7 +329,7 @@ class UserInviterOrderBy(enum.Enum):
|
|
289
329
|
|
290
330
|
|
291
331
|
class UserInviteListFilter(APIRequestModel):
|
292
|
-
callback: Optional[str]
|
332
|
+
callback: Optional[str] = None
|
293
333
|
callback__contains: Optional[List[str]] = None
|
294
334
|
callback__in: Optional[List[str]] = None
|
295
335
|
created_at: Optional[str] = None
|
@@ -343,7 +383,13 @@ class UserInviteDeleteResult(PangeaResponseResult):
|
|
343
383
|
|
344
384
|
class UserProfileGetRequest(APIRequestModel):
|
345
385
|
id: Optional[str] = None
|
386
|
+
"""The identity of a user or a service."""
|
387
|
+
|
346
388
|
email: Optional[str] = None
|
389
|
+
"""An email address."""
|
390
|
+
|
391
|
+
username: Optional[str] = None
|
392
|
+
"""A username."""
|
347
393
|
|
348
394
|
|
349
395
|
class UserProfileGetResult(User):
|
@@ -352,8 +398,16 @@ class UserProfileGetResult(User):
|
|
352
398
|
|
353
399
|
class UserProfileUpdateRequest(APIRequestModel):
|
354
400
|
profile: Profile
|
401
|
+
"""Updates to a user profile."""
|
402
|
+
|
355
403
|
id: Optional[str] = None
|
404
|
+
"""The identity of a user or a service."""
|
405
|
+
|
356
406
|
email: Optional[str] = None
|
407
|
+
"""An email address."""
|
408
|
+
|
409
|
+
username: Optional[str] = None
|
410
|
+
"""A username."""
|
357
411
|
|
358
412
|
|
359
413
|
class UserProfileUpdateResult(User):
|
@@ -362,9 +416,25 @@ class UserProfileUpdateResult(User):
|
|
362
416
|
|
363
417
|
class UserUpdateRequest(APIRequestModel):
|
364
418
|
id: Optional[str] = None
|
419
|
+
"""The identity of a user or a service."""
|
420
|
+
|
365
421
|
email: Optional[str] = None
|
422
|
+
"""An email address."""
|
423
|
+
|
366
424
|
disabled: Optional[bool] = None
|
425
|
+
"""
|
426
|
+
New disabled value. Disabling a user account will prevent them from logging
|
427
|
+
in.
|
428
|
+
"""
|
429
|
+
|
367
430
|
unlock: Optional[bool] = None
|
431
|
+
"""
|
432
|
+
Unlock a user account if it has been locked out due to failed authentication
|
433
|
+
attempts.
|
434
|
+
"""
|
435
|
+
|
436
|
+
username: Optional[str] = None
|
437
|
+
"""A username."""
|
368
438
|
|
369
439
|
|
370
440
|
class UserUpdateResult(User):
|
@@ -386,8 +456,16 @@ class ClientJWKSResult(PangeaResponseResult):
|
|
386
456
|
|
387
457
|
class UserAuthenticatorsDeleteRequest(APIRequestModel):
|
388
458
|
id: Optional[str] = None
|
459
|
+
"""The identity of a user or a service."""
|
460
|
+
|
389
461
|
email: Optional[str] = None
|
462
|
+
"""An email address."""
|
463
|
+
|
390
464
|
authenticator_id: str
|
465
|
+
"""An ID for an authenticator."""
|
466
|
+
|
467
|
+
username: Optional[str] = None
|
468
|
+
"""A username."""
|
391
469
|
|
392
470
|
|
393
471
|
class UserAuthenticatorsDeleteResult(PangeaResponseResult):
|
@@ -396,7 +474,13 @@ class UserAuthenticatorsDeleteResult(PangeaResponseResult):
|
|
396
474
|
|
397
475
|
class UserAuthenticatorsListRequest(APIRequestModel):
|
398
476
|
email: Optional[str] = None
|
477
|
+
"""An email address."""
|
478
|
+
|
399
479
|
id: Optional[str] = None
|
480
|
+
"""The identity of a user or a service."""
|
481
|
+
|
482
|
+
username: Optional[str] = None
|
483
|
+
"""A username."""
|
400
484
|
|
401
485
|
|
402
486
|
class UserAuthenticatorsListResult(PangeaResponseResult):
|