Skip to content
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

Remove oauth token endpoint #391

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
95ec2cf
fix(server): ensure configured port and hostname are used for issuer …
michaelruocco May 5, 2024
31f46ca
feat(api): adds endpoint for generating auth tokens
michaelruocco May 13, 2024
0c4ce6e
chore(release): updates to publish docker image under my own organisa…
michaelruocco May 13, 2024
6353d26
chore(release): bump commit to trigger pipeline
michaelruocco May 13, 2024
53c2967
chore(release): fix pipeline targets
michaelruocco May 13, 2024
faae1f8
chore(token): resolve linting issues
michaelruocco May 13, 2024
21a16b6
Merge pull request #1 from michaelruocco/fix-issuer-and-jwks-url
michaelruocco May 13, 2024
51360ce
chore(release): 1.0.0 [skip ci]
semantic-release-bot May 13, 2024
95160eb
chore(release): try to fix package name to fix name clash issue on pu…
michaelruocco May 13, 2024
2a68b9c
feat(release): bump commit to try and trigger release
michaelruocco May 13, 2024
bff064b
chore(release): 1.1.0 [skip ci]
semantic-release-bot May 13, 2024
86d71ba
feat(release): try public package name
michaelruocco May 13, 2024
a3adaf4
Merge branch 'master' of https://github.com/michaelruocco/cognito-local
michaelruocco May 13, 2024
9c4cc81
chore(release): 1.2.0 [skip ci]
semantic-release-bot May 13, 2024
479267f
fix(server): fixes issuer host configuration
michaelruocco May 13, 2024
9926b85
Merge branch 'master' of https://github.com/michaelruocco/cognito-local
michaelruocco May 13, 2024
db092b1
chore(tidyup): remove logic to add oauth token endpoint
michaelruocco Jun 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on:
push:
branches: [master]
pull_request_target:
pull_request:
branches: [master]

jobs:
Expand Down Expand Up @@ -98,4 +98,4 @@ jobs:
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- run: yarn install
- run: yarn build
- run: yarn build
510 changes: 303 additions & 207 deletions CHANGELOG.md

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cognito Local

![CI](https://github.com/jagregory/cognito-local/workflows/CI/badge.svg)
![CI](https://github.com/michaelruocco/cognito-local/workflows/CI/badge.svg)

A _Good Enough_ offline emulator for [Amazon Cognito](https://aws.amazon.com/cognito/).

Expand Down Expand Up @@ -220,13 +220,13 @@ cognito-local how to connect to your local Lambda server:

### via Docker

docker run --publish 9229:9229 jagregory/cognito-local:latest
docker run --publish 9229:9229 michaelruocco/cognito-local:latest

Cognito Local will now be listening on `http://localhost:9229`.

To persist your database between runs, mount the `/app/.cognito` volume to your host machine:

docker run --publish 9229:9229 --volume $(pwd)/.cognito:/app/.cognito jagregory/cognito-local:latest
docker run --publish 9229:9229 --volume $(pwd)/.cognito:/app/.cognito michaelruocco/cognito-local:latest

### via Node

Expand All @@ -252,12 +252,12 @@ environment variable:
If you're running in Docker, you can also rebind the [published ports](https://docs.docker.com/config/containers/container-networking/#published-ports)
when you run:

`docker run -p4000:9229 jagregory/cognito-local`
`docker run -p4000:9229 michaelruocco/cognito-local`

Or combine the two approaches by [setting an environment variable](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file)
when you run:

`docker run -p4000:4000 -e PORT=4000 jagregory/cognito-local`
`docker run -p4000:4000 -e PORT=4000 michaelruocco/cognito-local`

The same can be done in docker-compose with [environment variables](https://docs.docker.com/compose/environment-variables/#set-environment-variables-in-containers)
and [port binding](https://docs.docker.com/compose/networking/) in compose.
Expand Down Expand Up @@ -482,7 +482,7 @@ For example:

If a Custom Message lambda is configured, the output of the function invocation will be printed in the console too (verbosely!).

By default, confirmation codes are randomly generated. If set, the value assigned to the `CODE` environment variable will always be returned instead.
By default, confirmation codes are randomly generated. If set, the value assigned to the `CODE` environment variable will always be returned instead.

## Advanced

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "cognito-local",
"name": "mruocco-cognito-local",
"version": "0.0.0-development",
"license": "MIT",
"bin": "lib/bin/start.js",
Expand Down Expand Up @@ -101,7 +101,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/jagregory/cognito-local.git"
"url": "https://github.com/michaelruocco/cognito-local.git"
},
"release": {
"branches": [
Expand Down
8 changes: 4 additions & 4 deletions scripts/dockerBuildPush.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ major_version=${versionArr[0]}

docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag jagregory/cognito-local:latest \
--tag jagregory/cognito-local:${major_version}-latest \
--tag jagregory/cognito-local:${version} \
--tag michaelruocco/cognito-local:latest \
--tag michaelruocco/cognito-local:${major_version}-latest \
--tag michaelruocco/cognito-local:${version} \
--push \
.

echo "{\"name\":\"Docker\",\"url\":\"https://hub.docker.com/r/jagregory/cognito-local\"}"
echo "{\"name\":\"Docker\",\"url\":\"https://hub.docker.com/r/michaelruocco/cognito-local\"}"
1 change: 1 addition & 0 deletions src/__tests__/mockTokenGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import { TokenGenerator } from "../services/tokenGenerator";

export const newMockTokenGenerator = (): jest.Mocked<TokenGenerator> => ({
generate: jest.fn(),
generateWithClientCreds: jest.fn(),
});
6 changes: 4 additions & 2 deletions src/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export interface Config {
TokenConfig: TokenConfig;
}

const hostname = process.env.ISSUER_HOST ?? "localhost";
const port = process.env.PORT ?? "9229";

export const DefaultConfig: Config = {
LambdaClient: {
credentials: {
Expand All @@ -32,8 +35,7 @@ export const DefaultConfig: Config = {
UsernameAttributes: ["email"],
},
TokenConfig: {
// TODO: this needs to match the actual host/port we started the server on
IssuerDomain: "http://localhost:9229",
IssuerDomain: `http://${hostname}:${port}`,
},
KMSConfig: {
credentials: {
Expand Down
7 changes: 5 additions & 2 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ export const createServer = (
});
});

const hostname = process.env.ISSUER_HOST ?? "localhost";
const port = process.env.PORT ?? "9229";

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}`,
jwks_uri: `http://${hostname}:${port}/${req.params.userPoolId}/.well-known/jwks.json`,
issuer: `http://${hostname}:${port}/${req.params.userPoolId}`,
});
});

Expand Down
Loading