Skip to content

Commit 99cfa05

Browse files
authored
[VAULT DOCS] Update wonky redirects (#856)
* correcting broken redirects and updating redirect doc * add some notes about wildcards vs regex
1 parent df26d9d commit 99cfa05

File tree

3 files changed

+85
-38
lines changed

3 files changed

+85
-38
lines changed

content/vault/v1.20.x/content/docs/about-vault/how-vault-works.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ description: >-
77

88
# How Vault works
99

10-
1110
Vault is an identity-based secrets and encryption management system
1211
that centralizes secret management, rotates old credentials, generates
1312
credentials on demand, audits client interactions, and supports regulatory
@@ -35,7 +34,12 @@ them access to secrets or stored sensitive data.
3534

3635
## Core Vault workflow
3736

38-
Vault works primarily with tokens and a token is associated to the client's policy. Each policy is path-based and policy rules constrains the actions and accessibility to the paths for each client. With Vault, you can create tokens manually and assign them to your clients, or the clients can log in and obtain a token. The illustration below displays Vault's core workflow.
37+
Vault works primarily with tokens associated to a client policy. The path-based
38+
policy defines rules that constrain the actions and accessibility of the
39+
associated paths for each client.
40+
41+
Clients can authenticate against Vault to log in and obtain a token automatically
42+
or you can create tokens manually and explicitly assign them to your clients.
3943

4044
![Vault Workflow](/img/vault-workflow-diagram1.png)
4145

content/vault/v1.20.x/redirects.jsonc

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,11 @@
3030
"destination": "/vault/docs/agent-and-proxy/autoauth/methods/alicloud",
3131
"permanent": true
3232
},
33-
34-
// Explicit redirect for /agent/autoauth because the slug-ed redirect refuses
35-
// to work for some reason :\
36-
{
37-
"source": "/vault/docs/agent/autoauth",
38-
"destination": "/vault/docs/agent-and-proxy/autoauth",
39-
"permanent": true
40-
},
41-
33+
4234
// Redirect /agent/autoauth/* paths to /agent-and-proxy/autoauth/*
4335
{
44-
"source": "/vault/docs/agent/autoauth/:slug(.*)",
45-
"destination": "/vault/docs/agent-and-proxy/autoauth/:slug",
36+
"source": "/vault/docs/agent/autoauth/:slug*",
37+
"destination": "/vault/docs/agent-and-proxy/autoauth/:slug*",
4638
"permanent": true
4739
},
4840

@@ -61,8 +53,8 @@
6153
Range: 1.4.x through 1.13.x
6254
**/
6355
{
64-
"source": "/vault/docs/:version(v1\\.(?:[4-9]|1[0-3])\\.x)/agent-and-proxy/autoauth/:slug(.*)",
65-
"destination": "/vault/docs/:version/agent/autoauth/:slug",
56+
"source": "/vault/docs/:version(v1\\.(?:[4-9]|1[0-3])\\.x)/agent-and-proxy/autoauth/:slug*",
57+
"destination": "/vault/docs/:version/agent/autoauth/:slug*",
6658
"permanent": true
6759
},
6860

@@ -91,8 +83,8 @@
9183
"permanent": true
9284
},
9385
{
94-
"source": "/vault/docs/:version(v1\\.(?:8|9|1[0-3])\\.x)/agent-and-proxy/agent/caching/:slug(.*)",
95-
"destination": "/vault/docs/:version/agent/caching/:slug",
86+
"source": "/vault/docs/:version(v1\\.(?:8|9|1[0-3])\\.x)/agent-and-proxy/agent/caching/:slug*",
87+
"destination": "/vault/docs/:version/agent/caching/:slug*",
9688
"permanent": true
9789
},
9890
{
@@ -193,8 +185,8 @@
193185
"permanent": true
194186
},
195187
{
196-
"source": "/vault/docs/upgrading/deduplication/:slug(.*)",
197-
"destination": "/vault/docs/secrets/identity/deduplication/:slug",
188+
"source": "/vault/docs/upgrading/deduplication/:slug*",
189+
"destination": "/vault/docs/secrets/identity/deduplication/:slug*",
198190
"permanent": true
199191
},
200192

@@ -375,7 +367,7 @@
375367
Range: 1.11 through 1.18
376368
**/
377369
{
378-
"source": "/vault/docs/v:version(1\\.1[1-8]\\.x)/partners",
370+
"source": "/vault/docs/v:version(1\\.1[1-8]\\.x)/partners/:slug*",
379371
"destination": "/vault/docs/v:version/interoperability-matrix",
380372
"permanent": true
381373
},
@@ -389,18 +381,18 @@
389381
"permanent": true
390382
},
391383
{
392-
"source": "/vault/docs/install/:slug(.*)",
393-
"destination": "/vault/docs/get-vault/:slug",
384+
"source": "/vault/docs/install/:slug*",
385+
"destination": "/vault/docs/get-vault/:slug*",
394386
"permanent": true
395387
},
396388
{
397-
"source": "/vault/docs/platform/aws/:slug(.*)",
398-
"destination": "/vault/docs/deploy/aws/:slug",
389+
"source": "/vault/docs/platform/aws/:slug*",
390+
"destination": "/vault/docs/deploy/aws/:slug*",
399391
"permanent": true
400392
},
401393
{
402-
"source": "/vault/docs/platform/k8s/:slug(.*)",
403-
"destination": "/vault/docs/deploy/kubernetes/:slug",
394+
"source": "/vault/docs/platform/k8s/:slug*",
395+
"destination": "/vault/docs/deploy/kubernetes/:slug*",
404396
"permanent": true
405397
},
406398

@@ -539,8 +531,8 @@
539531

540532
// Corrected double-versioned URLs to just take the first version in the string
541533
{
542-
"source": "/vault/docs/:version(v1\\.*\\.x)/v:ver(1\\.*\\.x)/:slug(.*)",
543-
"destination": "/vault/docs/:version/:slug",
534+
"source": "/vault/docs/:version(v1\\.*\\.x)/v:ver(1\\.*\\.x)/:slug*",
535+
"destination": "/vault/docs/:version/:slug*",
544536
"permanent": true
545537
}
546538
]

docs/redirects.md

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,46 @@ Use redirects for fun and profit!
5656
URL.
5757

5858

59-
## Limitations and gotchas
59+
## Redirect slugs
6060

61-
- The `developers.hashicorp.com` platform does not support global redirects. The
62-
most current docset only knows about redirects associated with that docset.
61+
There are 3 types of slugs: placeholders, wildcards, and named path parameters.
6362

64-
- You must perpetuate backfacing redirects across future docsets. Otherwise,
65-
the most current version of a docset will "forget" how to handle the
66-
backfacing redirects.
63+
### Placeholders
6764

68-
- You cannot split redirects across multiple files. For example, you cannot
69-
create a file to define your backfacing redirects and include it in the main
70-
redirect file.
65+
Placeholders only match to a single path section in the source definition.
66+
67+
- Source definition: `:<name>`
68+
- Destination use: `:<name>`
69+
70+
For example, the source definition `/path/:slug` matches to `path/subpath` but
71+
not `path`, `path/`, or `/path/subpath/anothersubpath/`.
72+
73+
### Wildcards
74+
75+
Wildcards match to the root path (with or without a trailing slash) and all
76+
subpaths.
77+
78+
- Source definition: `:<name>*`
79+
- Destination use: `:<name>*`
80+
81+
For example, the source definition `/path/:slug*` matches to `path`, `path/`,
82+
`path/subpath`, and `/path/subpath/anothersubpath/`.
83+
84+
You must include the `*` character in the destination URL. Just using the slug
85+
name will not work properly.
86+
87+
### Named path parameters
88+
89+
Named parameters match to the corresponding pattern or non-capture group.
90+
Patterns and non-capture groups can include a single path segment, multiple path
91+
segments, or all subpaths.
92+
93+
- Source definition: `:<name>(<pattern or non-capture group>)`
94+
- Destination use: `:<name>`
95+
96+
For example, the source definition `/path/:slug(1\\.(?:9\|1[0-5])\\.x)` matches
97+
to `path/1.9.x` through `path/1.15.x` but not to `path`, `path/` or any other
98+
subpath.
7199

72100

73101
## Path parameter definition
@@ -117,6 +145,29 @@ Notation | Character set
117145

118146

119147

148+
## Limitations and gotchas
149+
150+
- Only the most recent redirect file matters. The `developers.hashicorp.com`
151+
platform only compiles redirects from the most recent redirect file.
152+
153+
- You must perpetuate backfacing redirects across future docsets. Otherwise, the
154+
most current version of a docset will "forget" how to handle the backfacing
155+
redirects.
156+
157+
- You cannot split redirects across multiple files. For example, you cannot
158+
create a file to define your backfacing redirects and include it in the main
159+
redirect file.
160+
161+
- If you use a non-capture group to capture subpaths, the redirect only works
162+
for the root path with the `/` included. For example, a source definition like
163+
`/path/:slug(.*)` works for `/path/path1` or `/path/`, but not for `/path`.
164+
To capture both forms of the root path, you need to include the `/` character
165+
as part of the non-capture group instead of the explicit path. For example,
166+
`/path:slug(/?.*)`. Unless you actually need a non-capture group for subpaths,
167+
wildcards are typically easier to read.
168+
169+
170+
120171
## Example path parameter definitions
121172

122173
Depending on the paths and page names you want to capture, there may be multiple
@@ -219,7 +270,7 @@ Use a non-capture group to redirect all child paths:
219270

220271
```json
221272
{
222-
"source": "/old/path/:slug(.*)",
273+
"source": "/old/path:slug(/?.*)",
223274
"destination": "/new/path/:slug",
224275
"permanent": true,
225276
}

0 commit comments

Comments
 (0)