Skip to content

Commit bbe21f6

Browse files
committed
feat: add verify_ssl flag
1 parent 4c8c835 commit bbe21f6

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/celine/sdk/auth/oidc.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ def __init__(
1818
client_secret: str,
1919
scope: str | None = None,
2020
timeout: float = 10.0,
21+
verify_ssl: bool = True,
2122
):
2223
super().__init__()
23-
self._discovery = OidcDiscoveryClient(base_url, timeout)
24+
self._discovery = OidcDiscoveryClient(base_url, timeout, verify_ssl=verify_ssl)
2425
self._client_id = client_id
2526
self._client_secret = client_secret
2627
self._scope = scope
2728
self._timeout = timeout
2829
self._token: AccessToken | None = None
30+
self._verify_ssl = verify_ssl
2931

3032
async def get_token(self) -> AccessToken:
3133
if self._token and self._token.is_valid():
@@ -53,7 +55,9 @@ async def _authenticate(self) -> AccessToken:
5355
if self._scope:
5456
data["scope"] = self._scope
5557

56-
async with httpx.AsyncClient(timeout=self._timeout) as client:
58+
async with httpx.AsyncClient(
59+
timeout=self._timeout, verify=self._verify_ssl
60+
) as client:
5761
r = await client.post(cfg.token_endpoint, data=data)
5862
r.raise_for_status()
5963
payload = r.json()
@@ -69,7 +73,9 @@ async def _refresh(self, refresh_token: str) -> AccessToken:
6973
"client_secret": self._client_secret,
7074
}
7175

72-
async with httpx.AsyncClient(timeout=self._timeout) as client:
76+
async with httpx.AsyncClient(
77+
timeout=self._timeout, verify=self._verify_ssl
78+
) as client:
7379
r = await client.post(cfg.token_endpoint, data=data)
7480
r.raise_for_status()
7581
payload = r.json()

src/celine/sdk/auth/oidc_discovery.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,22 @@ class OidcConfiguration:
1313

1414

1515
class OidcDiscoveryClient:
16-
def __init__(self, issuer_base_url: str, timeout: float = 10.0):
16+
def __init__(
17+
self, issuer_base_url: str, timeout: float = 10.0, verify_ssl: bool = True
18+
):
1719
self._issuer = issuer_base_url.rstrip("/")
1820
self._timeout = timeout
1921
self._config: OidcConfiguration | None = None
22+
self._verify_ssl = verify_ssl
2023

2124
async def get_config(self) -> OidcConfiguration:
2225
if self._config:
2326
return self._config
2427

2528
url = f"{self._issuer}/.well-known/openid-configuration"
26-
async with httpx.AsyncClient(timeout=self._timeout) as client:
29+
async with httpx.AsyncClient(
30+
timeout=self._timeout, verify=self._verify_ssl
31+
) as client:
2732
r = await client.get(url)
2833
r.raise_for_status()
2934
payload = r.json()

src/celine/sdk/settings/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class OidcSettings(BaseSettings):
1010
model_config = SettingsConfigDict(env_prefix="CELINE_OIDC_", extra="ignore")
1111

1212
timeout: float = 10.0
13+
verify_ssl: bool = Field(default=True, description="Verify TLS certificates")
1314

1415
scope: str | None = Field(default=None, description="OAuth2 scope string")
1516

0 commit comments

Comments
 (0)