Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #60 from Infisical/daniel/pg-fix
Browse files Browse the repository at this point in the history
Fix PG
  • Loading branch information
dangtony98 authored Jan 28, 2024
2 parents e7fb5c4 + f371696 commit 28bf675
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 26 deletions.
9 changes: 8 additions & 1 deletion infisical/api/create_secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@ def create_secret_req(api_request: Session, options: CreateSecretDTO) -> SecretR
"secretPath": options.path,
},
)

json_object = response.json()

json_object["secret"]["workspace"] = options.workspace_id
json_object["secret"]["environment"] = options.environment



return SecretResponse.parse_obj(response.json())
return SecretResponse.parse_obj(json_object)
7 changes: 6 additions & 1 deletion infisical/api/delete_secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ def delete_secret_req(api_request: Session, options: DeleteSecretDTO) -> SecretR
},
)

return SecretResponse.parse_obj(response.json())
json_object = response.json()

json_object["secret"]["workspace"] = options.workspace_id
json_object["secret"]["environment"] = options.environment

return SecretResponse.parse_obj(json_object)
7 changes: 6 additions & 1 deletion infisical/api/get_secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ def get_secret_req(api_request: Session, options: GetSecretDTO) -> SecretRespons
},
)

return SecretResponse.parse_obj(response.json())
json_object = response.json()

json_object["secret"]["workspace"] = options.workspace_id
json_object["secret"]["environment"] = options.environment

return SecretResponse.parse_obj(json_object)
14 changes: 13 additions & 1 deletion infisical/api/get_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ def get_secrets_req(api_request: Session, options: GetSecretsDTO) -> SecretsResp
"include_imports": str(options.include_imports).lower()
},
)
data = SecretsResponse.parse_obj(response.json())

json_object = response.json()

for obj in json_object['secrets']:
obj["workspace"] = options.workspace_id
obj["environment"] = options.environment

for obj in json_object['imports']:
for obj in obj['secrets']:
obj["workspace"] = options.workspace_id
obj["environment"] = options.environment

data = SecretsResponse.parse_obj(json_object)

return (data.secrets if data.secrets else [], data.imports if data.imports else [])

21 changes: 5 additions & 16 deletions infisical/api/models.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
from datetime import datetime
from typing import List, Optional
from typing import Optional

from pydantic import BaseModel, Field


class GetServiceTokenDetailsUserResponse(BaseModel):
id: str = Field(..., alias="_id")
email: str
created_at: datetime = Field(..., alias="createdAt")
updated_at: datetime = Field(..., alias="updatedAt")
v: int = Field(..., alias="__v")
first_name: str = Field(..., alias="firstName")
last_name: str = Field(..., alias="lastName")


class GetServiceTokenDetailsResponse(BaseModel):
id: str = Field(..., alias="_id")
id: str = Field(..., alias="id")
name: str
workspace: str
user: GetServiceTokenDetailsUserResponse
workspace: str = Field(..., alias="projectId")
expires_at: Optional[datetime] = Field(None, alias="expiresAt")
encrypted_key: str = Field(..., alias="encryptedKey")
iv: str
tag: str
created_at: datetime = Field(..., alias="createdAt")
updated_at: datetime = Field(..., alias="updatedAt")
v: int = Field(..., alias="__v")
#v: int = Field(..., alias="__v")

class KeyData(BaseModel):
id: str = Field(..., alias="_id")
id: str = Field(..., alias="id")
workspace: str
encrypted_key: str = Field(..., alias="encryptedKey")
public_key: str = Field(..., alias="publicKey")
Expand Down
7 changes: 6 additions & 1 deletion infisical/api/update_secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ def update_secret_req(api_request: Session, options: UpdateSecretDTO) -> SecretR
},
)

return SecretResponse.parse_obj(response.json())
json_object = response.json()

json_object["secret"]["workspace"] = options.workspace_id
json_object["secret"]["environment"] = options.environment

return SecretResponse.parse_obj(json_object)
2 changes: 1 addition & 1 deletion infisical/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
AUTH_MODE_SERVICE_TOKEN = "service_token"
AUTH_MODE_SERVICE_TOKEN_V3 = "service_token_v3"

SERVICE_TOKEN_REGEX = re.compile(r"(st\.[a-f0-9]+\.[a-f0-9]+)\.([a-f0-9]+)")
SERVICE_TOKEN_REGEX = re.compile(r"(st\.[a-f0-9-]+\.[a-f0-9]+)\.([a-f0-9]+)")
8 changes: 4 additions & 4 deletions infisical/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class Secret(BaseModel):
id: str = Field(..., alias="_id")
id: str = Field(..., alias="id")
version: int
workspace: str
user: Optional[str]
Expand All @@ -26,8 +26,8 @@ class SecretBundle(BaseModel):
secret_name: str
secret_value: Optional[str]
version: Optional[int]
workspace: Optional[str]
environment: Optional[str]
# workspace: Optional[str]
# environment: Optional[str]
type: Optional[Literal["shared", "personal"]]
created_at: Optional[datetime] = Field(None, alias="createdAt")
updated_at: Optional[datetime] = Field(None, alias="updatedAt")
Expand All @@ -36,7 +36,7 @@ class SecretBundle(BaseModel):


class ServiceTokenData(BaseModel):
id: str = Field(..., alias="_id")
id: str = Field(..., alias="id")
name: str
workspace: str
environment: str
Expand Down

0 comments on commit 28bf675

Please sign in to comment.