Compare commits

..

4 Commits

Author SHA1 Message Date
github-actions[bot]
fdaaf19057 chore: update versions (#2844)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @nhost/dashboard@1.27.0

### Minor Changes

-   a7cd02c: fix: resolve rate limit query

## @nhost/docs@2.16.0

### Minor Changes

-   ba55c1b: feat: run: added a guide on using a private registry
-   3d70c63: feat: added rate-limiter guide for auth service

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-08-27 14:51:52 +01:00
David BM
a7cd02c965 fix (dashboard): resolve rate limit query (#2845)
### **PR Type**
Bug fix, Enhancement


___

### **Description**
- Removed the 'Auth' switch from the `AuthLimitingForm` component to
simplify the settings interface.
- Updated the rate limit query in `useGetRateLimits` hook to resolve by
default, fixing a potential issue.
- Added a changeset to document the fix for the rate limit query.



___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>AuthLimitingForm.tsx</strong><dd><code>Remove 'Auth'
switch from AuthLimitingForm component</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>


dashboard/src/features/projects/rate-limiting/settings/components/AuthLimitingForm/AuthLimitingForm.tsx

<li>Removed the 'Auth' switch from the settings container.<br> <li>
Simplified the form component by removing unused props.<br>


</details>


  </td>
<td><a
href="https://github.com/nhost/nhost/pull/2845/files#diff-cd300f74c3d921fde5b705b25f63e22a3e66dfb9182ca818102cb1a5f508eb5e">+0/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    
</table></td></tr><tr><td><strong>Bug fix</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>useGetRateLimits.ts</strong><dd><code>Update rate limit
query to resolve by default</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>


dashboard/src/features/projects/rate-limiting/settings/hooks/useGetRateLimits/useGetRateLimits.ts

- Changed the 'resolve' variable to true in the rate limit query.



</details>


  </td>
<td><a
href="https://github.com/nhost/nhost/pull/2845/files#diff-82e380da100404643bd31504d42eb4d27a406dd9e1cccffc17b9dbcb0df5e8fa">+1/-1</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    
</table></td></tr><tr><td><strong>Documentation</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>smooth-bears-confess.md</strong><dd><code>Add changeset
for rate limit query fix</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

.changeset/smooth-bears-confess.md

- Added a changeset for the rate limit query fix.



</details>


  </td>
<td><a
href="https://github.com/nhost/nhost/pull/2845/files#diff-7def3298a6278543c9953ddf387b04c552ddefc4cd5ad9217366c59926b3cf63">+5/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    
</table></td></tr></tr></tbody></table>

___

> 💡 **PR-Agent usage**:
>Comment `/help` on the PR to get a list of all available PR-Agent tools
and their descriptions

---------

Co-authored-by: Hassan Ben Jobrane <hsanbenjobrane@gmail.com>
2024-08-27 14:45:08 +01:00
David Barroso
3d70c63d1b feat (docs): added docs about rate-limits (#2812) 2024-08-27 15:17:03 +02:00
David Barroso
ba55c1b779 feat (docs): run: added a guide on using a private registry (#2843) 2024-08-27 12:36:09 +02:00
12 changed files with 183 additions and 6 deletions

View File

@@ -1,5 +1,11 @@
# @nhost/dashboard
## 1.27.0
### Minor Changes
- a7cd02c: fix: resolve rate limit query
## 1.26.0
### Minor Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/dashboard",
"version": "1.26.0",
"version": "1.27.0",
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",

View File

@@ -248,8 +248,6 @@ export default function AuthLimitingForm() {
>
<SettingsContainer
title="Auth"
switchId="enabled"
showSwitch
slotProps={{
submitButton: {
disabled: !formState.isDirty || maintenanceActive,

View File

@@ -13,7 +13,7 @@ export default function useGetRateLimits() {
const { data, loading } = useGetRateLimitConfigQuery({
variables: {
appId: currentProject?.id,
resolve: false,
resolve: true,
},
skip: !currentProject,
...(!isPlatform ? { client: localMimirClient } : {}),

View File

@@ -1,5 +1,12 @@
# @nhost/docs
## 2.16.0
### Minor Changes
- ba55c1b: feat: run: added a guide on using a private registry
- 3d70c63: feat: added rate-limiter guide for auth service
## 2.15.0
### Minor Changes

View File

@@ -93,3 +93,56 @@ Wait a few seconds until the project is done updating the new service and visit
![visit url](/images/guides/run/registry_7.png)
## Using your own private registry
If you are publishing your images in your own private registry you can add pull credentials to your Run configuration so the image can be pulled successfully. To do so follow the next steps:
1. Figure out the credentials you need. This might depend on your registry. For instructions on various registries see the next section.
2. The credentials will be similar to:
```json
{
"auths": {
"https://myregistry.com/v1": {
"username": "myuser",
"password": "mypassword"
}
}
}
```
3. Create a secret under Settings -> Secrets with the contents of the auth section. For instance:
![pull secret](/images/guides/run/registry_8.png)
Pay attention that **only** the object inside "auths" is to be added.
4. Configure the `pullCredentials` in your run configuration.
```toml
[image]
image = 'myprivaterepo/myservice:1.0.1'
pullCredentials = '{{ secrets.CONTAINER_REGISTRY_CREDENTIALS }}'
```
Pulling your image should work now.
### Docker Hub Credentials
To create a credential that allows you to pull private images from Docker hub follow the next steps:
1. Login to https://hub.docker.com with a user that can pull the image you want.
2. Head to "Account Settings" -> "Personal access tokens"
3. Create a new token with "Read Only" access permissions
4. Copy the token you got
Your credentials will be:
```json
{
"https://index.docker.io/v1/": {
"username":"<yourusername>",
"password":"<the_token_you_just_got>"
}
}
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 KiB

View File

@@ -84,7 +84,8 @@
"platform/environment-variables",
"platform/secrets",
"platform/deployments",
"platform/custom-domains"
"platform/custom-domains",
"platform/rate-limits"
]
},
{

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/docs",
"version": "2.15.0",
"version": "2.16.0",
"private": true,
"scripts": {
"start": "mintlify dev"

View File

@@ -0,0 +1,112 @@
---
title: Rate Limits
sidebarTitle: Rate Limits
description: Protecting your service against abuse
icon: shield
---
Rate limits in an HTTP API are essential for protecting services against abuse and brute force attacks by restricting the number of requests a client can make within a specified time period. By enforcing rate limits, we can mitigate the risk of unauthorized access, denial of service attacks, and excessive consumption of resources.
Limits work by setting a maximum number of requests (burst amount) allowed for a key within a specified time frame (recovery time). For example, with a limit of 30 requests and a recovery time of 5 minutes, a user can make up to 30 requests before hitting the limit. Additionally, the user receives an extra request every 10 seconds (5 * 60 / 30) until reaching the limit.
## GraphQL/Storage/Functions
You can rate-limit the GraphQL, Storage, and Functions services independently of each other. These rate limits are based on the client IP, and requests made to one service do not count toward the rate limits of another service.
### Configuration
<Tabs>
<Tab title="Dashboard">
**Project Dashboard -> Settings -> Rate Limiting**
![Rate limit services](/images/platform/rate-limiting/misc.png)
</Tab>
<Tab title="Config">
```toml
[hasura.rateLimit]
limit = 100
interval = '15m'
[functions.rateLimit]
limit = 100
interval = '15m'
[storage.rateLimit]
limit = 100
interval = '15m'
```
</Tab>
</Tabs>
## Auth
Given that not all endpoints are equally sensitive, Auth supports more complex rate-limiting rules, allowing you to set different configurations depending on the properties of each endpoint.
| Endpoints | Key | Limits | Description | Minimum version |
| ----------------------|-----|--------|-------------|-----------------|
| Any that sends emails<sup>1</sup> | Global | 50 / hour | Not configurable. This limit applies to any project without custom SMTP settings | 0.33.0 |
| Any that sends emails<sup>1</sup> | Client IP | 10 / hour | Configurable. This limit applies to any project with custom SMTP settings and is configurable | 0.33.0 |
| Any that sends SMS<sup>2</sup> | Client IP | 10 / hour | Configurable. | 0.33.0 |
| Any endpoint that an attacker may try to brute-force. This includes sign-in and verify endpoints<sup>3</sup> | Client IP | 10 / 5 minutes | Configurable | 0.33.0 |
| Signup endpoints<sup>4</sup> | Client IP | 10 / 5 minutes | Configurable | 0.33.0 |
| Any | Client IP | 100 / minute | The total sum of requests to any endpoint (including previous ones) can not exceed this limit | 0.33.0 |
<Note>
Limits are grouped within a given category. For instance, with a limit of 10 per hour for the sign-in/verify category, if a user attempts to sign in 10 times and then tries to verify an OTP code, the latter will be rate-limited alongside the sign-in attempts.
</Note>
<sup>1</sup> Paths included:
- `/signin/passwordless/email`
- `/user/email/change`
- `/user/email/send-verification-email`
- `/user/password/reset`
- `/signup/email-password` - If email verification enabled
- `/user/deanonymize` - If email verification enabled
<sup>2</sup> Paths included:
- `/signin/passwordless/sms`
<sup>3</sup> Paths included:
- `/signin/*`
- `*/verify`
- `*/otp`
<sup>4</sup> Paths included:
- `/signup/*`
### Configuration
<Tabs>
<Tab title="Dashboard">
**Project Dashboard -> Settings -> Rate Limiting**
![Rate limit Auth](/images/platform/rate-limiting/auth.png)
</Tab>
<Tab title="Config">
```toml
[auth.rateLimit]
[auth.rateLimit.emails]
limit = 10
interval = '1h'
[auth.rateLimit.sms]
limit = 10
interval = '1h'
[auth.rateLimit.bruteForce]
limit = 10
interval = '5m'
[auth.rateLimit.signups]
limit = 10
interval = '5m'
[auth.rateLimit.global]
limit = 100
interval = '1m'
```
</Tab>
</Tabs>