Commit fc257d4
Add support for adding base-route for Runtime (#1506)
## Why make this change?
SWA or any other front end can interact with DAB using a path-based
routing mechanism, where they may use a path (`base-route`) to redirect
requests to DAB (refer to the bug encountered:
#1420). This
`base-route` gets stripped off when the request lands at DAB.
Consequently, DAB is not even aware of anything like a `base-route`
being used by the front end.
This poses a problem in generation of the `nextLink`, where the
`nextLink` which DAB generates, does not contain the `base-route` and
consequently when the front end receives the next request, it does not
find the base route in the request URL and hence, has no idea where to
redirect the request to.
Using the newly added option to configure base route for rest requests
via the config (CLI option - `--runtime.base-route`), the front-end like
SWA can make DAB aware that they are using a base route to redirect
requests to DAB. DAB can then accordingly account for the base route
while generating the `nextLink` for paginated responses.
## What is this change?
1. Added feature to specify `base-route` in global runtime settings in
the config which can be via CLI as well using `--runtime.base-route
`option in the `dab init` command. By default, it will be initialized as
null. When the base-route is a non-empty string, it will be included in
the generated nextLink. This feature is only supported when
`authentication provider == StaticWebApps`. We throw an exception when
base-route is configured for non-SWA providers.
2. Extended functionality of `Utils.IsApiPathValid(string? apiPath,
ApiType apiType)` method to `Utils.IsUriComponentValid(string?
uriComponent)` because similar validations are required for api
properties: `rest.path`/ `runtime.base-route`/ `graphql.path`, all of
which are part of the request URI.
3. Renamed `RuntimeConfigValidator.ValidateRestPathForRelationalDbs()`
to `RuntimeConfigValidator.ValidateRestURI()`.
4. Renamed `RuntimeConfigValidator.ValidateGraphQLPath()` to
`RuntimeConfigValidator.ValidateGraphQLURI()` so that we follow same
convention between rest and gql.
## Q&A
1. Will this require updating an already created configuration file?
No, the existing config file will work perfectly fine. The base-route is
totally an optional feature.
2. Will a default value be implicitly used if the new base path config
property is not set?
The default value for the base-route is null. This essentially means
that base-route will not come into the picture.
3. What is the default value and does the value differ between dev/prod
swa/non-swa?
The default value will be same irrespective of dev/prod/swa/non-swa
environment and equal to null.
So to say, the **change is not a breaking change and we are totally
backwards compatible**.
## How was this tested?
- [x] Integration Tests - Was added to `ConfigurationTests.cs` to assert
that the generated nextLink contains the base-route.
- [x] Unit tests - were added to `ConfigValidationUnitTests.cs` to
confirm that we throw proper exceptions when runtime base-route is
formatted incorrectly (contains reserved characters or doesn't start
with a '/') or when base-route is configured for non-SWA authentication
providers.
---------
Co-authored-by: Aaron Powell <me@aaron-powell.com>
Co-authored-by: Sean Leonard <sean.leonard@microsoft.com>
Co-authored-by: Aniruddh Munde <anmunde@microsoft.com>1 parent bda0d65 commit fc257d4
File tree
15 files changed
+362
-262
lines changed- src
- Cli.Tests
- Cli
- Commands
- Config/ObjectModel
- Core
- Configurations
- Resolvers
- Services/OpenAPI
- Service.Tests
- Configuration
- Unittests
15 files changed
+362
-262
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
| 107 | + | |
109 | 108 | | |
110 | 109 | | |
111 | 110 | | |
| |||
720 | 719 | | |
721 | 720 | | |
722 | 721 | | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
723 | 758 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
849 | 849 | | |
850 | 850 | | |
851 | 851 | | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | | - | |
878 | | - | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
893 | | - | |
894 | | - | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | 852 | | |
899 | 853 | | |
900 | 854 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
183 | 183 | | |
184 | | - | |
| 184 | + | |
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
92 | 97 | | |
93 | 98 | | |
94 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| |||
147 | 149 | | |
148 | 150 | | |
149 | 151 | | |
150 | | - | |
| 152 | + | |
151 | 153 | | |
| 154 | + | |
152 | 155 | | |
153 | 156 | | |
154 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
155 | 179 | | |
156 | 180 | | |
157 | 181 | | |
| |||
166 | 190 | | |
167 | 191 | | |
168 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
169 | 199 | | |
170 | 200 | | |
171 | 201 | | |
| |||
183 | 213 | | |
184 | 214 | | |
185 | 215 | | |
186 | | - | |
| 216 | + | |
| 217 | + | |
187 | 218 | | |
188 | 219 | | |
189 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
184 | 183 | | |
185 | 184 | | |
186 | 185 | | |
187 | | - | |
| 186 | + | |
188 | 187 | | |
189 | | - | |
190 | | - | |
191 | | - | |
| 188 | + | |
| 189 | + | |
192 | 190 | | |
193 | | - | |
194 | | - | |
195 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
196 | 194 | | |
197 | 195 | | |
198 | 196 | | |
199 | 197 | | |
200 | | - | |
201 | | - | |
| 198 | + | |
| 199 | + | |
202 | 200 | | |
203 | | - | |
| 201 | + | |
204 | 202 | | |
205 | 203 | | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
| 204 | + | |
216 | 205 | | |
217 | 206 | | |
218 | 207 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
39 | 45 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
0 commit comments