Skip to content

Commit e691bdc

Browse files
authored
Merge pull request #45 from Infisical/daniel/token-auth
feat(auth): oidc auth support
2 parents 94788ee + df5fbdc commit e691bdc

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

infisical_sdk/resources/auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from infisical_sdk.infisical_requests import InfisicalRequests
22
from infisical_sdk.resources.auth_methods import AWSAuth
33
from infisical_sdk.resources.auth_methods import UniversalAuth
4-
4+
from infisical_sdk.resources.auth_methods import OidcAuth
55
from typing import Callable
66
class Auth:
77
def __init__(self, requests: InfisicalRequests, setToken: Callable[[str], None]):
88
self.requests = requests
99
self.aws_auth = AWSAuth(requests, setToken)
10-
self.universal_auth = UniversalAuth(requests, setToken)
10+
self.universal_auth = UniversalAuth(requests, setToken)
11+
self.oidc_auth = OidcAuth(requests, setToken)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
from .aws_auth import AWSAuth
22
from .universal_auth import UniversalAuth
3+
from .oidc_auth import OidcAuth
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from infisical_sdk.api_types import MachineIdentityLoginResponse
2+
3+
from typing import Callable
4+
from infisical_sdk.infisical_requests import InfisicalRequests
5+
6+
class OidcAuth:
7+
def __init__(self, requests: InfisicalRequests, setToken: Callable[[str], None]):
8+
self.requests = requests
9+
self.setToken = setToken
10+
11+
def login(self, identity_id: str, jwt: str) -> MachineIdentityLoginResponse:
12+
"""
13+
Login with OIDC Auth.
14+
15+
Args:
16+
identity_id (str): Your Machine Identity ID.
17+
jwt (str): Your OIDC JWT.
18+
19+
Returns:
20+
MachineIdentityLoginResponse: A response object containing the access token and related information.
21+
"""
22+
23+
requestBody = {
24+
"identityId": identity_id,
25+
"jwt": jwt
26+
}
27+
28+
result = self.requests.post(
29+
path="/api/v1/auth/oidc-auth/login",
30+
json=requestBody,
31+
model=MachineIdentityLoginResponse
32+
)
33+
34+
self.setToken(result.data.accessToken)
35+
36+
return result.data

0 commit comments

Comments
 (0)