Skip to content

Commit

Permalink
Merge pull request jagregory#350 from root0x/openid-configuration
Browse files Browse the repository at this point in the history
fix: add openid-configuration endpoint
  • Loading branch information
jagregory authored Mar 21, 2024
2 parents e757ecc + 006a7dc commit 6b57c1b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14-alpine as builder
FROM node:16-alpine as builder
WORKDIR /app

# dependencies
Expand All @@ -20,4 +20,4 @@ EXPOSE 9229
ENV HOST 0.0.0.0
ENV PORT 9229
VOLUME /app/.cognito
ENTRYPOINT ["node", "/app/start.js"]
ENTRYPOINT ["node", "/app/start.js"]
16 changes: 16 additions & 0 deletions integration-tests/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,20 @@ describe("HTTP server", () => {
});
});
});

describe("OpenId Configuration Endpoint", () => {
it("responds with open id configuration", async () => {
const server = createServer(jest.fn(), MockLogger as any);

const response = await supertest(server.application).get(
"/any-user-pool/.well-known/openid-configuration"
);
expect(response.status).toEqual(200);
expect(response.body).toEqual({
id_token_signing_alg_values_supported: ["RS256"],
jwks_uri: `http://localhost:9229/any-user-pool/.well-known/jwks.json`,
issuer: `http://localhost:9229/any-user-pool`,
});
});
});
});
8 changes: 8 additions & 0 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ export const createServer = (
});
});

app.get("/:userPoolId/.well-known/openid-configuration", (req, res) => {
res.status(200).json({
id_token_signing_alg_values_supported: ["RS256"],
jwks_uri: `http://localhost:9229/${req.params.userPoolId}/.well-known/jwks.json`,
issuer: `http://localhost:9229/${req.params.userPoolId}`,
});
});

app.get("/health", (req, res) => {
res.status(200).json({ ok: true });
});
Expand Down

0 comments on commit 6b57c1b

Please sign in to comment.