-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Hackweek 2025 Policy Wizard #31375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Hackweek 2025 Policy Wizard #31375
Changes from 15 commits
6f5d634
e15cc06
eaaf3a3
5dd3335
f725892
4428e36
2bd04b5
1e1528b
eddbeb5
cc67a19
565f962
d8eb2ce
1000e21
c08ba1b
6dcf033
d9c7d2b
fc2c882
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maps route to API paths |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (c) HashiCorp, Inc. | ||
* SPDX-License-Identifier: BUSL-1.1 | ||
*/ | ||
|
||
import apiPath from './api-path'; | ||
|
||
const API_PATHS = { | ||
kvv2: { | ||
overview: [apiPath`${'backend'}/data/${'path'}`, apiPath`${'backend'}/metadata/${'path'}`], | ||
subkeys: [apiPath`${'backend'}/subkeys/${'path'}`, apiPath`${'backend'}/data/${'path'}`], | ||
}, | ||
secretsList: [apiPath`${'backend'}/`], | ||
}; | ||
|
||
// Regex-based route matching - more flexible for parent/child relationships | ||
const ROUTE_PATTERNS: Array<{ pattern: RegExp; paths: ReturnType<typeof apiPath>[] }> = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this is one way to do this, I think it would be better and less effort to plug this into the existing capabilities service instead. That already handles permissions requests for various views. We could cache the requested paths and use those to map a route to a view instead of manually mapping route to api paths. |
||
// KV v2 routes - matches any kv secret route | ||
{ | ||
pattern: /^vault\.cluster\.secrets\.backend\.kv\.secret\.patch/, | ||
paths: API_PATHS.kvv2.subkeys, | ||
}, | ||
{ | ||
pattern: /^vault\.cluster\.secrets\.backend\.kv/, | ||
paths: API_PATHS.kvv2.overview, | ||
}, | ||
{ | ||
pattern: /^vault\.cluster\.secrets\./, | ||
paths: API_PATHS.secretsList, | ||
}, | ||
]; | ||
|
||
export default function mapApiPathToRoute(routeName: string): ReturnType<typeof apiPath>[] { | ||
// Try pattern matching | ||
for (const { pattern, paths } of ROUTE_PATTERNS) { | ||
if (pattern.test(routeName)) { | ||
return paths; | ||
} | ||
} | ||
|
||
return []; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💣 just deleted everything that was breaking
SuperSelect
in the flyout 🙃