Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 49 additions & 19 deletions docs/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,8 @@
<h1 class="title"> </h1>
</header>
<h1 id="lightspeed-core-stack">Lightspeed Core Stack</h1>
<h2 id="base-url">🌍 Base URL</h2>
<table>
<thead>
<tr class="header">
<th>URL</th>
<th>Description</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<h1 id="apis">🛠️ APIs</h1>
<hr />
<h1 id="components">📋 Components</h1>
<h1 id="configuration-schema">📋 Configuration schema</h1>
<h2 id="accessrule">AccessRule</h2>
<p>Rule defining what actions a role can perform.</p>
<table>
Expand Down Expand Up @@ -317,7 +305,27 @@ <h2 id="byokrag">ByokRag</h2>
</table>
<h2 id="corsconfiguration">CORSConfiguration</h2>
<p>CORS configuration.</p>
<p>CORS or ‘Cross-Origin Resource Sharing’ refers to the situations when
a frontend running in a browser has JavaScript code that communicates
with a backend, and the backend is in a different ‘origin’ than the
frontend.</p>
<p>Useful resources:</p>
<ul>
<li><a href="https://fastapi.tiangolo.com/tutorial/cors/">CORS in
FastAPI</a></li>
<li><a
href="https://en.wikipedia.org/wiki/Cross-origin_resource_sharing">Wikipedia
article</a></li>
<li><a
href="https://dev.to/akshay_chauhan/what-is-cors-explained-8f1">What is
CORS?</a></li>
</ul>
<table>
<colgroup>
<col style="width: 26%" />
<col style="width: 23%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr class="header">
<th>Field</th>
Expand All @@ -329,22 +337,30 @@ <h2 id="corsconfiguration">CORSConfiguration</h2>
<tr class="odd">
<td>allow_origins</td>
<td>array</td>
<td></td>
<td>A list of origins allowed for cross-origin requests. An origin is
the combination of protocol (http, https), domain (myapp.com, localhost,
localhost.tiangolo.com), and port (80, 443, 8080). Use [’*’] to allow
all origins.</td>
</tr>
<tr class="even">
<td>allow_credentials</td>
<td>boolean</td>
<td></td>
<td>Indicate that cookies should be supported for cross-origin
requests</td>
</tr>
<tr class="odd">
<td>allow_methods</td>
<td>array</td>
<td></td>
<td>A list of HTTP methods that should be allowed for cross-origin
requests. You can use [’*’] to allow all standard methods.</td>
</tr>
<tr class="even">
<td>allow_headers</td>
<td>array</td>
<td></td>
<td>A list of HTTP request headers that should be supported for
cross-origin requests. You can use [’*’] to allow all headers. The
Accept, Accept-Language, Content-Language and Content-Type headers are
always allowed for simple CORS requests.</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -981,8 +997,22 @@ <h2 id="serviceconfiguration">ServiceConfiguration</h2>
</table>
<h2 id="tlsconfiguration">TLSConfiguration</h2>
<p>TLS configuration.</p>
<p>See also: - https://fastapi.tiangolo.com/deployment/https/ -
https://en.wikipedia.org/wiki/Transport_Layer_Security</p>
<p>Transport Layer Security (TLS) is a cryptographic protocol designed
to provide communications security over a computer network, such as the
Internet. The protocol is widely used in applications such as email,
instant messaging, and voice over IP, but its use in securing HTTPS
remains the most publicly visible.</p>
<p>Useful resources:</p>
<ul>
<li><a href="https://fastapi.tiangolo.com/deployment/https/">FastAPI
HTTPS Deployment</a></li>
<li><a
href="https://en.wikipedia.org/wiki/Transport_Layer_Security">Transport
Layer Security Overview</a></li>
<li><a
href="https://www.ssltrust.eu/learning/ssl/transport-layer-security-tls">What
is TLS</a></li>
</ul>
<table>
<colgroup>
<col style="width: 26%" />
Expand Down
44 changes: 26 additions & 18 deletions docs/config.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
# Lightspeed Core Stack



## 🌍 Base URL


| URL | Description |
|-----|-------------|


# 🛠️ APIs

---

# 📋 Components
# 📋 Configuration schema



Expand Down Expand Up @@ -85,13 +75,23 @@ BYOK RAG configuration.

CORS configuration.

CORS or 'Cross-Origin Resource Sharing' refers to the situations when a
frontend running in a browser has JavaScript code that communicates with a
backend, and the backend is in a different 'origin' than the frontend.

Useful resources:

- [CORS in FastAPI](https://fastapi.tiangolo.com/tutorial/cors/)
- [Wikipedia article](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)
- [What is CORS?](https://dev.to/akshay_chauhan/what-is-cors-explained-8f1)
Comment on lines +78 to +86
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix list indentation for markdown compliance.

The unordered list items in the "Useful resources" section are indented by 2 spaces. Remove the indentation to comply with MD007.

Apply this diff:

 Useful resources:
 
-  - [CORS in FastAPI](https://fastapi.tiangolo.com/tutorial/cors/)
-  - [Wikipedia article](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)
-  - [What is CORS?](https://dev.to/akshay_chauhan/what-is-cors-explained-8f1)
+- [CORS in FastAPI](https://fastapi.tiangolo.com/tutorial/cors/)
+- [Wikipedia article](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)
+- [What is CORS?](https://dev.to/akshay_chauhan/what-is-cors-explained-8f1)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
CORS or 'Cross-Origin Resource Sharing' refers to the situations when a
frontend running in a browser has JavaScript code that communicates with a
backend, and the backend is in a different 'origin' than the frontend.
Useful resources:
- [CORS in FastAPI](https://fastapi.tiangolo.com/tutorial/cors/)
- [Wikipedia article](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)
- [What is CORS?](https://dev.to/akshay_chauhan/what-is-cors-explained-8f1)
CORS or 'Cross-Origin Resource Sharing' refers to the situations when a
frontend running in a browser has JavaScript code that communicates with a
backend, and the backend is in a different 'origin' than the frontend.
Useful resources:
- [CORS in FastAPI](https://fastapi.tiangolo.com/tutorial/cors/)
- [Wikipedia article](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)
- [What is CORS?](https://dev.to/akshay_chauhan/what-is-cors-explained-8f1)
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

84-84: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


85-85: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


86-86: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)

🤖 Prompt for AI Agents
In docs/config.md around lines 78 to 86, the "Useful resources" unordered list
items are indented by two spaces which violates MD007; remove the leading two
spaces before each list item so the hyphens start at the left margin (no leading
spaces) to make the markdown list top-level and compliant.



| Field | Type | Description |
|-------|------|-------------|
| allow_origins | array | |
| allow_credentials | boolean | |
| allow_methods | array | |
| allow_headers | array | |
| allow_origins | array | A list of origins allowed for cross-origin requests. An origin is the combination of protocol (http, https), domain (myapp.com, localhost, localhost.tiangolo.com), and port (80, 443, 8080). Use ['*'] to allow all origins. |
| allow_credentials | boolean | Indicate that cookies should be supported for cross-origin requests |
| allow_methods | array | A list of HTTP methods that should be allowed for cross-origin requests. You can use ['*'] to allow all standard methods. |
| allow_headers | array | A list of HTTP request headers that should be supported for cross-origin requests. You can use ['*'] to allow all headers. The Accept, Accept-Language, Content-Language and Content-Type headers are always allowed for simple CORS requests. |


## Configuration
Expand Down Expand Up @@ -373,9 +373,17 @@ Service configuration.

TLS configuration.

See also:
- https://fastapi.tiangolo.com/deployment/https/
- https://en.wikipedia.org/wiki/Transport_Layer_Security
Transport Layer Security (TLS) is a cryptographic protocol designed to
provide communications security over a computer network, such as the
Internet. The protocol is widely used in applications such as email,
instant messaging, and voice over IP, but its use in securing HTTPS remains
the most publicly visible.

Useful resources:

- [FastAPI HTTPS Deployment](https://fastapi.tiangolo.com/deployment/https/)
- [Transport Layer Security Overview](https://en.wikipedia.org/wiki/Transport_Layer_Security)
- [What is TLS](https://www.ssltrust.eu/learning/ssl/transport-layer-security-tls)
Comment on lines +376 to +386
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix list indentation for markdown compliance.

The unordered list items in the "Useful resources" section are indented by 2 spaces. Remove the indentation to comply with MD007.

Apply this diff:

 Useful resources:
 
-  - [FastAPI HTTPS Deployment](https://fastapi.tiangolo.com/deployment/https/)
-  - [Transport Layer Security Overview](https://en.wikipedia.org/wiki/Transport_Layer_Security)
-  - [What is TLS](https://www.ssltrust.eu/learning/ssl/transport-layer-security-tls)
+- [FastAPI HTTPS Deployment](https://fastapi.tiangolo.com/deployment/https/)
+- [Transport Layer Security Overview](https://en.wikipedia.org/wiki/Transport_Layer_Security)
+- [What is TLS](https://www.ssltrust.eu/learning/ssl/transport-layer-security-tls)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Transport Layer Security (TLS) is a cryptographic protocol designed to
provide communications security over a computer network, such as the
Internet. The protocol is widely used in applications such as email,
instant messaging, and voice over IP, but its use in securing HTTPS remains
the most publicly visible.
Useful resources:
- [FastAPI HTTPS Deployment](https://fastapi.tiangolo.com/deployment/https/)
- [Transport Layer Security Overview](https://en.wikipedia.org/wiki/Transport_Layer_Security)
- [What is TLS](https://www.ssltrust.eu/learning/ssl/transport-layer-security-tls)
Transport Layer Security (TLS) is a cryptographic protocol designed to
provide communications security over a computer network, such as the
Internet. The protocol is widely used in applications such as email,
instant messaging, and voice over IP, but its use in securing HTTPS remains
the most publicly visible.
Useful resources:
- [FastAPI HTTPS Deployment](https://fastapi.tiangolo.com/deployment/https/)
- [Transport Layer Security Overview](https://en.wikipedia.org/wiki/Transport_Layer_Security)
- [What is TLS](https://www.ssltrust.eu/learning/ssl/transport-layer-security-tls)
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

384-384: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


385-385: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


386-386: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)

🤖 Prompt for AI Agents
In docs/config.md around lines 376 to 386, the "Useful resources" unordered list
items are indented by two spaces which violates MD007; remove the leading
two-space indentation so each list item starts at the beginning of the line (no
leading spaces), keeping the dash and a single space then the link text, to
produce a top-level unordered list that complies with markdown linting.



| Field | Type | Description |
Expand Down
8 changes: 4 additions & 4 deletions docs/config.puml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class "ByokRag" as src.models.config.ByokRag {
vector_db_id : Annotated
}
class "CORSConfiguration" as src.models.config.CORSConfiguration {
allow_credentials : bool
allow_headers : list[str]
allow_methods : list[str]
allow_origins : list[str]
allow_credentials : Optional[bool]
allow_headers : Optional[list[str]]
allow_methods : Optional[list[str]]
allow_origins : Optional[list[str]]
check_cors_configuration() -> Self
}
class "Configuration" as src.models.config.Configuration {
Expand Down
78 changes: 65 additions & 13 deletions src/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,17 @@ class ConfigurationBase(BaseModel):
class TLSConfiguration(ConfigurationBase):
"""TLS configuration.

See also:
- https://fastapi.tiangolo.com/deployment/https/
- https://en.wikipedia.org/wiki/Transport_Layer_Security
Transport Layer Security (TLS) is a cryptographic protocol designed to
provide communications security over a computer network, such as the
Internet. The protocol is widely used in applications such as email,
instant messaging, and voice over IP, but its use in securing HTTPS remains
the most publicly visible.

Useful resources:

- [FastAPI HTTPS Deployment](https://fastapi.tiangolo.com/deployment/https/)
- [Transport Layer Security Overview](https://en.wikipedia.org/wiki/Transport_Layer_Security)
- [What is TLS](https://www.ssltrust.eu/learning/ssl/transport-layer-security-tls)
"""

tls_certificate_path: Optional[FilePath] = Field(
Expand Down Expand Up @@ -68,14 +76,51 @@ def check_tls_configuration(self) -> Self:


class CORSConfiguration(ConfigurationBase):
"""CORS configuration."""
"""CORS configuration.

CORS or 'Cross-Origin Resource Sharing' refers to the situations when a
frontend running in a browser has JavaScript code that communicates with a
backend, and the backend is in a different 'origin' than the frontend.

Useful resources:

allow_origins: list[str] = [
"*"
] # not AnyHttpUrl: we need to support "*" that is not valid URL
allow_credentials: bool = False
allow_methods: list[str] = ["*"]
allow_headers: list[str] = ["*"]
- [CORS in FastAPI](https://fastapi.tiangolo.com/tutorial/cors/)
- [Wikipedia article](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)
- [What is CORS?](https://dev.to/akshay_chauhan/what-is-cors-explained-8f1)
"""

# not AnyHttpUrl: we need to support "*" that is not valid URL
allow_origins: list[str] = Field(
["*"],
title="Allow origins",
description="A list of origins allowed for cross-origin requests. An origin "
"is the combination of protocol (http, https), domain "
"(myapp.com, localhost, localhost.tiangolo.com), and port (80, 443, 8080). "
"Use ['*'] to allow all origins.",
)

allow_credentials: bool = Field(
False,
title="Allow credentials",
description="Indicate that cookies should be supported for cross-origin requests",
)

allow_methods: list[str] = Field(
["*"],
title="Allow methods",
description="A list of HTTP methods that should be allowed for "
"cross-origin requests. You can use ['*'] to allow "
"all standard methods.",
)

allow_headers: list[str] = Field(
["*"],
title="Allow headers",
description="A list of HTTP request headers that should be supported "
"for cross-origin requests. You can use ['*'] to allow all headers. The "
"Accept, Accept-Language, Content-Language and Content-Type headers are "
"always allowed for simple CORS requests.",
)

@model_validator(mode="after")
def check_cors_configuration(self) -> Self:
Expand All @@ -85,8 +130,8 @@ def check_cors_configuration(self) -> Self:
if self.allow_credentials and "*" in self.allow_origins:
raise ValueError(
"Invalid CORS configuration: allow_credentials can not be set to true when "
"allow origins contains '*' wildcard."
"Use explicit origins or disable credential."
"allow origins contains the '*' wildcard."
"Use explicit origins or disable credentials."
)
return self

Expand Down Expand Up @@ -183,7 +228,14 @@ class ServiceConfiguration(ConfigurationBase):
tls_certificate_path=None, tls_key_path=None, tls_key_password=None
)
)
cors: CORSConfiguration = Field(default_factory=CORSConfiguration)
cors: CORSConfiguration = Field(
default_factory=lambda: CORSConfiguration(
allow_origins=["*"],
allow_credentials=False,
allow_methods=["*"],
allow_headers=["*"],
)
)

@model_validator(mode="after")
def check_service_configuration(self) -> Self:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/models/config/test_cors.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def test_cors_improper_configuration() -> None:
"""Test the CORS configuration."""
expected = (
"Value error, Invalid CORS configuration: "
+ "allow_credentials can not be set to true when allow origins contains '\\*' wildcard."
+ "Use explicit origins or disable credential."
+ "allow_credentials can not be set to true when allow origins contains the '\\*' wildcard."
+ "Use explicit origins or disable credentials."
Comment on lines +67 to +68
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Missing space causes sentence concatenation issue.

Line 68 lacks a leading space, causing the two sentences to concatenate without separation: "...wildcard.Use explicit...". This will cause the test to fail unless the actual error message also has this formatting issue.

Apply this diff to add the missing space:

-        + "Use explicit origins or disable credentials."
+        + " Use explicit origins or disable credentials."
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
+ "allow_credentials can not be set to true when allow origins contains the '\\*' wildcard."
+ "Use explicit origins or disable credentials."
"allow_credentials can not be set to true when allow origins contains the '\\*' wildcard."
" Use explicit origins or disable credentials."
🤖 Prompt for AI Agents
In tests/unit/models/config/test_cors.py around lines 67 to 68, the two string
literals are concatenated without a space resulting in "...wildcard.Use
explicit..." — add a leading space at the start of the second string (or add a
trailing space to the first) so the sentences are separated ("...wildcard. Use
explicit origins or disable credentials.") to match the expected error message.

)

with pytest.raises(ValueError, match=expected):
Expand Down
Loading