Commit 1d43c41
Support for ignoring extraneous fields in rest request body (#1608)
## Why make this change?
Add support for allowing extraneous fields in request body as per:
#1606.
## What is this change?
DAB will expose another CLI option in the `init` command
`rest.request-body-strict`, which when set to true/false, would set the
property `runtime.rest.request-body-strict` as `true`/`false` in the
generated runtime config file. What this essentially means is that, as
part of the REST mutations (POST/PUT/PATCH), there can be extraneous
fields present in the request body and they will be ignored. Default
behavior of DAB will continue to be the same as what it is today, i.e.
any extraneous fields in the request body would return an error. So to
say, the default value of `runtime.rest.request-body-strict` is `true`.
## Additional change
Refactored `RequestValidator.cs` class to be a singleton dependent on
`ISqlMetaDataProvider` and `RuntimeConfigProvider` services. Better
presents its dependency on the two services and simplifies the code.
## What are the different extraneous fields?
1. Fields in request body that do not map to any backing column in the
table/view. They will be ignored.
2. Fields that are repeated - present as PK in the request URL for
PUT/PATCH requests and also present in the request body. The ones in the
request body will be ignored.
3. Read-only fields. The support for this will be added in a subsequent
PR: #1596.
-> Read-only field are: **Computed** (or Generated) / **AutoGenerated**
fields in MsSql/MySql/PgSql
-> **timestamp** fields in MsSql
## Questions:
**1. What about authorization of extraneous fields?**
When operating in flexible mode, the user is _not_ authorized for
extraneous fields NOT defined on table because those fields are ignored.
For all other cases, authorization goes as usual.
## How was this tested?
- [x] Integration Tests - Added tests to validate that extraneous fields
are allowed in the request body for all the 3 relational DBs in the
`{*}RestBodyNonStrictModeTests.cs` classes inheriting from the base
class `RestBodyNonStrictModeTests.cs`. (* = MsSql,MySql,PostgreSql)
- [x] Unit Tests - Added unit test to validate the functionality of the
newly added --`rest.request-body-strict` feature in the init command.
---------
Co-authored-by: Aniruddh Munde <[email protected]>1 parent 987df9e commit 1d43c41
158 files changed
Lines changed: 1499 additions & 228 deletions
File tree
- config-generators
- schemas
- src
- Cli.Tests
- Snapshots
- Cli
- Commands
- Config
- Converters
- ObjectModel
- Core
- Authorization
- Configurations
- Resolvers
- Services
- Service.Tests
- Authorization/GraphQL
- Policies
- Configuration
- Snapshots
- SqlTests
- GraphQLFilterTests
- GraphQLMutationTests
- GraphQLPaginationTests
- GraphQLQueryTests
- GraphQLSupportedTypesTests
- RestApiTests
- Delete
- Find
- Insert
- Patch
- Put
- RestBodyNonStrictModeTests
- RestBootstrapTests
- Unittests
- Service
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
136 | 141 | | |
137 | 142 | | |
138 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
| 158 | + | |
| 159 | + | |
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
| |||
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
| 187 | + | |
| 188 | + | |
186 | 189 | | |
187 | 190 | | |
188 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
829 | 829 | | |
830 | 830 | | |
831 | 831 | | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
832 | 860 | | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
0 commit comments