Skip to content

Commit 1af52f5

Browse files
deepakprabhakaraunatasha8
authored andcommitted
chore: added oel configuration schemas (#2279)
* WIP * temp hack for oathkeeper schema id * temp hack for oathkeeper schema id * revert schema urls * - added new config pages for OEL - updated dep - resolve internal refs in ory resolvers correctly
1 parent f6ab4ff commit 1af52f5

File tree

8 files changed

+94
-11
lines changed

8 files changed

+94
-11
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
id: configuration
3+
title: OEL Configuration
4+
---
5+
6+
```mdx-code-block
7+
import ConfigMarkdown from '@site/src/components/ConfigMarkdown';
8+
9+
<ConfigMarkdown src="https://raw.githubusercontent.com/ory/keto/refs/heads/master/embedx/config.schema.json" binary="keto" />
10+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
id: configuration
3+
title: OEL Configuration
4+
---
5+
6+
```mdx-code-block
7+
import ConfigMarkdown from '@site/src/components/ConfigMarkdown';
8+
9+
<ConfigMarkdown src="https://raw.githubusercontent.com/ory/kratos/refs/heads/master/embedx/config.schema.json" binary="kratos" />
10+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
id: configuration
3+
title: OEL Configuration
4+
---
5+
6+
```mdx-code-block
7+
import ConfigMarkdown from '@site/src/components/ConfigMarkdown';
8+
9+
<ConfigMarkdown src="https://raw.githubusercontent.com/ory/oathkeeper/refs/heads/master/spec/config.schema.json" binary="oathkeeper" />
10+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
id: configuration
3+
title: OEL Configuration
4+
---
5+
6+
```mdx-code-block
7+
import ConfigMarkdown from '@site/src/components/ConfigMarkdown';
8+
9+
<ConfigMarkdown src="https://raw.githubusercontent.com/ory/hydra/refs/heads/master/spec/config.json" binary="hydra" />
10+
```

package-lock.json

Lines changed: 8 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
]
3030
},
3131
"dependencies": {
32-
"@apidevtools/json-schema-ref-parser": "11.7.3",
32+
"@apidevtools/json-schema-ref-parser": "14.2.0",
3333
"@docusaurus/core": "3.8.0",
3434
"@docusaurus/plugin-client-redirects": "3.8.0",
3535
"@docusaurus/plugin-content-docs": "3.8.0",

src/components/ConfigMarkdown/index.tsx

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ const parser = new RefParser()
1313
const refs = {
1414
"ory://tracing-config": `https://raw.githubusercontent.com/ory/x/master/otelx/config.schema.json`,
1515
"ory://logging-config": `https://raw.githubusercontent.com/ory/x/master/logrusx/config.schema.json`,
16+
"ory://serve-config": `https://raw.githubusercontent.com/ory/x/master/configx/serve.schema.json`,
17+
"ory://cors-config": `https://raw.githubusercontent.com/ory/x/master/configx/cors.schema.json`,
18+
"ory://tls-config": `https://raw.githubusercontent.com/ory/x/master/configx/tls.schema.json`,
1619
}
1720

1821
const enhance =
@@ -113,7 +116,36 @@ const enhance =
113116
export const oryResolver = {
114117
order: 1,
115118
canRead: /^ory:/i,
116-
read: ({ url }) => axios.get(refs[url]).then(({ data }) => data),
119+
read: ({ url }) =>
120+
axios.get(refs[url]).then(({ data }) => {
121+
// Manually resolve internal $refs for schemas that have this issue
122+
const resolveInternalRefs = (obj, definitions) => {
123+
if (typeof obj === "object" && obj !== null) {
124+
for (const key in obj) {
125+
if (
126+
key === "$ref" &&
127+
typeof obj[key] === "string" &&
128+
obj[key].startsWith("#/definitions/")
129+
) {
130+
const defName = obj[key].replace("#/definitions/", "")
131+
if (definitions && definitions[defName]) {
132+
// Replace the $ref with the actual definition
133+
delete obj["$ref"]
134+
Object.assign(obj, definitions[defName])
135+
}
136+
} else if (typeof obj[key] === "object") {
137+
resolveInternalRefs(obj[key], definitions)
138+
}
139+
}
140+
}
141+
}
142+
143+
if (data.definitions) {
144+
resolveInternalRefs(data, data.definitions)
145+
}
146+
147+
return data
148+
}),
117149
}
118150

119151
export default function ConfigMarkdown(props: { src: string; binary: string }) {
@@ -132,6 +164,10 @@ export default function ConfigMarkdown(props: { src: string; binary: string }) {
132164
.then((r) => r.json())
133165
.then((schema) => {
134166
new Promise((resolve, reject) => {
167+
if (schema.title === "ORY Oathkeeper Configuration") {
168+
schema["$id"] =
169+
"https://github.com/ory/oathkeeper/schema/config.schema.json"
170+
}
135171
parser.dereference(
136172
schema,
137173
{

src/sidebar.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,7 @@ const oel: SidebarItemsConfig = [
12371237
"self-hosted/oel/oauth2/token-prefix",
12381238
"self-hosted/oel/oauth2/migrate-postgresql-ttl",
12391239
"self-hosted/oel/oauth2/revert-database-migrations",
1240+
"self-hosted/oel/oauth2/configuration",
12401241
],
12411242
},
12421243
{
@@ -1245,6 +1246,7 @@ const oel: SidebarItemsConfig = [
12451246
items: [
12461247
"self-hosted/oel/oathkeeper/upgrade-oathkeeper",
12471248
"self-hosted/oel/oathkeeper/changelog",
1249+
"self-hosted/oel/oathkeeper/configuration",
12481250
],
12491251
},
12501252
{
@@ -1253,8 +1255,14 @@ const oel: SidebarItemsConfig = [
12531255
items: [
12541256
"self-hosted/oel/kratos/upgrade",
12551257
"self-hosted/oel/kratos/changelog",
1258+
"self-hosted/oel/kratos/configuration",
12561259
],
12571260
},
1261+
{
1262+
type: "category",
1263+
label: "Ory Keto Permissions",
1264+
items: ["self-hosted/oel/keto/configuration"],
1265+
},
12581266
{
12591267
type: "category",
12601268
label: "Ory Polis",

0 commit comments

Comments
 (0)