source-cooperative / source.coop

Source Cooperative Web Interface & API
https://source.coop
MIT License
10 stars 0 forks source link

[Bug] [local dev env] unable to login with Ory #38

Closed severo closed 3 days ago

severo commented 1 week ago

Description of Bug:

I followed the setup steps from https://github.com/source-cooperative/source.coop/blob/main/README.md. But after logging in successfully with Ory, I'm not logged in the local source.coop.

Maybe I overlooked some Ory configuration step.

Steps to Reproduce:

I created an account in https://ory.sh.

I created a new workspace called source.coop:

Screenshot From 2024-11-21 14-28-51

I selected the "Development" environment and confirmed:

Screenshot From 2024-11-21 14-29-29

Screenshot From 2024-11-21 14-29-59

Inside the workspace, I created a project:

Screenshot From 2024-11-21 14-30-38

I called it "localauth":

Screenshot From 2024-11-21 14-31-28

I selected the "development" environment

Screenshot From 2024-11-21 14-31-48

and confirmed

Screenshot From 2024-11-21 14-32-15

Then, I went to the "Project settings" tab, then the "API keys" sub menu entry, and clicked "Create new API key"

Screenshot From 2024-11-21 14-33-37

I called it localauthkey and set the expiration to 90 days

Screenshot From 2024-11-21 14-34-45

then copied the new API key

Screenshot From 2024-11-21 14-35-26

I pasted this key to the .env file:

ORY_ACCESS_TOKEN=ory_pat_xxxxxxx

then I went to the "Project settings" tab and "Overview" sub menu entry and copied the API URL:

Screenshot From 2024-11-21 14-37-45

I pasted this URL to the .env file:

ORY_SDK_URL=https://quirky-caxxxxxxxx.projects.oryapis.com

In my browser I deleted the cookies for http://localhost:3000/.

Then I ran

npm run dev

And went to http://localhost:3000/

There, I clicked "Sign in / register", and signed up with an email and a new password.

Screencast From 2024-11-21 14-46-18.webm

But nothing happened, and I looped in the same state, without being logged in, or being able to try to login again, or having an error that explains what happens.

Expected Behavior:

I would be logged in after signing up.

Or, alternatively, I would get an error that explains why I cannot be logged in.

Actual Behavior:

I'm not logged in after registering a new user, and I have no error in the UI, and nothing in the logs either.

Logs

> source-cooperative@0.1.3 dev
> scripts/db_start.sh && next dev

Checking if the S3 container is already running...
Container 'source-s3' is already running.
S3 is running at http://localhost:5050
Checking if the DynamoDB container is already running...
Container 'source-dynamodb' is already running.
DynamoDB is running at http://localhost:8000
Initializing tables...
(node:292812) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:292824) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Loaded env from /home/severo/dev/source-cooperative/source.coop/.env.local
info  - Loaded env from /home/severo/dev/source-cooperative/source.coop/.env
event - compiled client and server successfully in 740 ms (659 modules)

After opening http://localhost:3000/, and before and after signing up, I got occurrences of:

[14:42:05.698] ERROR (292824): You are not authorized to perform this action
    err: {
      "type": "UnauthorizedError",
      "message": "You are not authorized to perform this action",
      "stack":
          UnauthorizedError: You are not authorized to perform this action
              at whoamiHandler (webpack-internal:///(api)/./src/pages/api/v1/whoami.ts:21:15)
              at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
              at async eval (webpack-internal:///(api)/./src/api/middleware/index.ts:20:13)
              at async Object.apiResolver (/home/severo/dev/source-cooperative/source.coop/node_modules/next/dist/server/api-utils/node.js:372:9)
              at async DevServer.runApi (/home/severo/dev/source-cooperative/source.coop/node_modules/next/dist/server/next-server.js:488:9)
              at async Object.fn (/home/severo/dev/source-cooperative/source.coop/node_modules/next/dist/server/next-server.js:751:37)
              at async Router.execute (/home/severo/dev/source-cooperative/source.coop/node_modules/next/dist/server/router.js:253:36)
              at async DevServer.run (/home/severo/dev/source-cooperative/source.coop/node_modules/next/dist/server/base-server.js:384:29)
              at async DevServer.run (/home/severo/dev/source-cooperative/source.coop/node_modules/next/dist/server/dev/next-dev-server.js:741:20)
              at async DevServer.handleRequest (/home/severo/dev/source-cooperative/source.coop/node_modules/next/dist/server/base-server.js:322:20)
      "name": "UnauthorizedError"
    }

Screenshots:

Additional Context:

$ npm --version
10.9.0
$ node --version
v22.9.0
$ nvm --version
0.40.1
$ docker --version
Docker version 27.3.1, build ce12230
$ uname -a
Linux msi 6.11.0-9-generic #9-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 14 13:19:59 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.10
Release:        24.10
Codename:       oracular
severo commented 1 week ago

Note also that I confirmed my email, and that I'm able to log in https://quirky-xxxxxxxx.projects.oryapis.com/ui/sessions and see my session.

severo commented 3 days ago

OK, the bug was unrelated to Ory. AWS CLI had to be installed and configured. See #40.