Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.

Commit a0d9999

Browse files
committed
[DOCUMENTATION]: Environment Variables
1 parent 27d638c commit a0d9999

File tree

7 files changed

+105
-19
lines changed

7 files changed

+105
-19
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,4 @@ pre-commit install
1111
```
1212
# **REFERENCES**
1313
### [**Jaseci**](./docs/Jaseci.md)
14-
### [**Jaseci**](./docs/Jaseci.md)
15-
### [**Jaseci**](./docs/Jaseci.md)
16-
### [**Jaseci**](./docs/Jaseci.md)
14+
### [**Environment Variables**](./docs/Environment-Variables.md)

docs/Environment-Variables.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
[<< back to main](../README.md)
2+
# **Supported Environment Variable**
3+
4+
| **NAME** | **DESCRIPTION** | **DEFAULT** |
5+
|-----------|-------------------|---------------|
6+
| HOST | FastAPI's host argument | 0.0.0.0 |
7+
| PORT | FastAPI's port argument | 8000 |
8+
| DATABASE_HOST | MongoDB connection string | mongodb://localhost/?retryWrites=true&w=majority |
9+
| DATABASE_NAME | MongoDB database name | jaseci |
10+
| REDIS_HOST | Redis connection host | redis://localhost |
11+
| REDIS_PORT | Redis connection port | 6379 |
12+
| REDIS_USER | Redis connection username | null |
13+
| REDIS_PASS | Redis connection password | null |
14+
| DISABLE_AUTO_CLEANUP | Disable auto deletion of nodes that doesn't connect to anything | false |
15+
| SINGLE_QUERY | Every edge_ref will trigger query per anchor if not already cached instead of consolidating non cached anchor before querying. | false |
16+
| SESSION_MAX_TRANSACTION_RETRY | MongoDB's transactional retry | 1 |
17+
| DISABLE_AUTO_ENDPOINT | Disable auto convertion of walker to api. It will now require inner class __specs__ or @specs decorator. | false |
18+
| SHOW_ENDPOINT_RETURNS | Include per visit return on api response | false |
19+
| SESSION_MAX_COMMIT_RETRY | MongoDB's transaction commit retry | 1 |
20+
| RESTRICT_UNVERIFIED_USER | Rstrict user's login until it has verified | false |
21+
| TOKEN_SECRET | Random string used to encrypt token | 50 random characters |
22+
| TOKEN_ALGORITHM | Algorithm used to encrypt token | HS256 |
23+
| TOKEN_TIMEOUT | Token expiration in hours | 12 |
24+
| VERIFICATION_CODE_TIMEOUT | Verification code expiration in hours | 24 |
25+
| RESET_CODE_TIMEOUT | Password reset code expiration in hours | 24 |
26+
| SENDGRID_HOST | Sendgrid host used for hyperlinking verification/reset code | http://localhost:8000 |
27+
| SENDGRID_API_KEY | Sendgrid api key | null |
28+
29+
# **SSO Supported Enviroment Variable**
30+
## Supported Platform
31+
- APPLE
32+
- FACEBOOK
33+
- FITBIT
34+
- GITHUB
35+
- GITLAB
36+
- GOOGLE
37+
- KAKAO
38+
- LINE
39+
- LINKEDIN
40+
- MICROSOFT
41+
- NAVER
42+
- NOTION
43+
- TWITTER
44+
- YANDEX
45+
46+
| **NAME** | **DESCRIPTION** |
47+
|-----------|-------------------|
48+
| SSO_`{PLATFORM}`_CLIENT_ID | platform's client id |
49+
| SSO_`{PLATFORM}`_CLIENT_SECRET | platform's client secret |
50+
| SSO_`{PLATFORM}`_ALLOW_INSECURE_HTTP | set if platform allow insecure http connection |
51+
| SSO_GITLAB_BASE_ENDPOINT_URL | gitlab base endpoint url |
52+
| SSO_MICROSOFT_TENANT | microsoft tenant |
53+
54+
## Apple Client Secret Auto Generation
55+
- for certificate: Just use either SSO_APPLE_CLIENT_CERTIFICATE_PATH or SSO_APPLE_CLIENT_CERTIFICATE
56+
57+
| **NAME** | **DESCRIPTION** |
58+
|-----------|-------------------|
59+
| SSO_APPLE_CLIENT_ID | apple's client id |
60+
| SSO_APPLE_CLIENT_TEAM_ID | apple's client team id |
61+
| SSO_APPLE_CLIENT_KEY | apple's client key |
62+
| SSO_APPLE_CLIENT_CERTIFICATE_PATH | apple's client certificate path |
63+
| SSO_APPLE_CLIENT_CERTIFICATE | apple's client certificate raw content |

docs/Jaseci.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,25 @@ with entry:__main__ {
145145
port=8001
146146
);
147147
}
148+
```
149+
150+
## **Walker Response Structure**
151+
- Response support auto serialization of walker/edge/node architypes and obj as long as it's attributes is also serializable (ex: nested dataclass)
152+
153+
```python
154+
{
155+
"status": {{ int : http status code }},
156+
"reports": {{ list : jac reports }},
157+
158+
# optional via SHOW_ENDPOINT_RETURNS=true environment variable
159+
"returns" {{ list : jac per visit return }}
160+
}
161+
```
162+
163+
## **Walker/Edge/Node Serialization**
164+
```python
165+
{
166+
"id": {{ str : anchor ref_id }},
167+
"context": {{ dict : anchor architype data }}
168+
}
148169
```

jaclang_jaseci/core/architype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class BulkWrite:
8080
"""Bulk Write builder."""
8181

8282
SESSION_MAX_TRANSACTION_RETRY: ClassVar[int] = int(
83-
getenv("SESSION_TRANSACTION_MAX_RETRY") or "1"
83+
getenv("SESSION_MAX_TRANSACTION_RETRY") or "1"
8484
)
8585
SESSION_MAX_COMMIT_RETRY: ClassVar[int] = int(
8686
getenv("SESSION_MAX_COMMIT_RETRY") or "1"

jaclang_jaseci/jaseci/routers/sso.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,19 @@
5858
SSO_HOST = getenv("SSO_HOST", "http://localhost:8000/sso")
5959

6060
for platform, cls in SUPPORTED_PLATFORMS.items():
61-
if client_id := getenv(f"{platform}_CLIENT_ID"):
61+
if client_id := getenv(f"SSO_{platform}_CLIENT_ID"):
6262
options: dict[str, Any] = {
6363
"client_id": client_id,
64-
"client_secret": getenv(f"{platform}_CLIENT_SECRET"),
64+
"client_secret": getenv(f"SSO_{platform}_CLIENT_SECRET"),
6565
}
6666

67-
if base_endpoint_url := getenv(f"{platform}_BASE_ENDPOINT_URL"):
67+
if base_endpoint_url := getenv(f"SSO_{platform}_BASE_ENDPOINT_URL"):
6868
options["base_endpoint_url"] = base_endpoint_url
6969

70-
if tenant := getenv(f"{platform}_TENANT"):
70+
if tenant := getenv(f"SSO_{platform}_TENANT"):
7171
options["tenant"] = tenant
7272

73-
if allow_insecure_http := getenv(f"{platform}_ALLOW_INSECURE_HTTP"):
73+
if allow_insecure_http := getenv(f"SSO_{platform}_ALLOW_INSECURE_HTTP"):
7474
options["allow_insecure_http"] = allow_insecure_http == "true"
7575

7676
if cls in CUSTOM_PLATFORMS:

jaclang_jaseci/jaseci/sso/apple.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,20 @@ def __init__(
4545
"""Apple SSO init."""
4646
if not client_secret:
4747
if (
48-
(client_team_id := getenv(f"{platform}_CLIENT_TEAM_ID"))
49-
and (client_team_id := getenv(f"{platform}_CLIENT_TEAM_ID"))
50-
and (client_key := getenv(f"{platform}_CLIENT_KEY"))
48+
(client_team_id := getenv(f"SSO_{platform}_CLIENT_TEAM_ID"))
49+
and (client_team_id := getenv(f"SSO_{platform}_CLIENT_TEAM_ID"))
50+
and (client_key := getenv(f"SSO_{platform}_CLIENT_KEY"))
5151
and (
5252
(
5353
client_certificate_path := getenv(
54-
f"{platform}_CLIENT_CERTIFICATE_PATH"
54+
f"SSO_{platform}_CLIENT_CERTIFICATE_PATH"
55+
)
56+
)
57+
or (
58+
client_certificate := getenv(
59+
f"SSO_{platform}_CLIENT_CERTIFICATE"
5560
)
5661
)
57-
or (client_certificate := getenv(f"{platform}_CLIENT_CERTIFICATE"))
5862
)
5963
):
6064
self.client_team_id = client_team_id
@@ -65,10 +69,10 @@ def __init__(
6569
self.client_certificate = client_certificate
6670
else:
6771
raise AttributeError(
68-
f"Please provide {platform}_CLIENT_SECRET or all required fields to auto generate secret!\n"
69-
f"{platform}_CLIENT_TEAM_ID\n"
70-
f"{platform}_CLIENT_KEY\n"
71-
f"{platform}_CLIENT_CERTIFICATE_PATH or {platform}_CLIENT_CERTIFICATE"
72+
f"Please provide SSO_{platform}_CLIENT_SECRET or all required fields to auto generate secret!\n"
73+
f"SSO_{platform}_CLIENT_TEAM_ID\n"
74+
f"SSO_{platform}_CLIENT_KEY\n"
75+
f"SSO_{platform}_CLIENT_CERTIFICATE_PATH or SSO_{platform}_CLIENT_CERTIFICATE"
7276
)
7377

7478
super().__init__(

jaclang_jaseci/jaseci/utils/mail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def send_reset_code(cls, code: str, email: str) -> None:
6060
class SendGridEmailer(Emailer):
6161
"""SendGrid Handler."""
6262

63-
__host__: str = getenv("HOST") or "http://localhost:8000"
63+
__host__: str = getenv("SENDGRID_HOST") or "http://localhost:8000"
6464

6565
@classmethod
6666
def generate_client(cls) -> SendGridAPIClient | None:

0 commit comments

Comments
 (0)