Skip to content

Commit d691416

Browse files
committed
Add /oauth/inspect endpoint
1 parent 17c777f commit d691416

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

components/server/src/oauth-server/oauth-controller.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { inject, injectable } from "inversify";
1515
import { URL } from "url";
1616
import { Config } from "../config";
1717
import { clientRepository, createAuthorizationServer } from "./oauth-authorization-server";
18+
import { inMemoryDatabase } from "./db";
1819

1920
@injectable()
2021
export class OAuthController {
@@ -175,6 +176,17 @@ export class OAuthController {
175176
}
176177
});
177178

179+
router.get("/oauth/inspect", async (req: express.Request, res: express.Response) => {
180+
const clientId = req.query.client as string;
181+
if (typeof clientId !== "string" || !Object.keys(inMemoryDatabase.clients).includes(clientId)) {
182+
return res.sendStatus(400);
183+
}
184+
185+
const client = inMemoryDatabase.clients[clientId];
186+
const scopes = client.scopes.map((s) => s.name);
187+
return res.send(scopes);
188+
});
189+
178190
return router;
179191
}
180192
}

0 commit comments

Comments
 (0)