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

Created readonly user not able to login #8

Closed
dingosky opened this issue Jan 27, 2025 · 4 comments
Closed

Created readonly user not able to login #8

dingosky opened this issue Jan 27, 2025 · 4 comments

Comments

@dingosky
Copy link
Collaborator

Create a user with readonly role:

curl -X 'POST' \
  'http://localhost:8083/v1/users' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <ADMIN_TOKEN>' \
  -d '{
  "username": "readonly",
  "password": "readonly",
  "role": "ReadOnly",
  "affiliation": "MBARI",
  "firstName": "read",
  "lastName": "only",
  "email": "[email protected]"
}'

Response:

{
 "username":"readonly",
  "password":"Z76g1k3o4Ylg8TW1s6uceE0cURziPMKm",
  "role":"ReadOnly",
  "affiliation":"MBARI",
  "firstName":"read",
  "lastName":"only",
  "email":"[email protected]",
  "id":243,
  "isEncrypted":true
}

Attempt to login to newly created user yields

{
  "message":"Invalid username or password",
  "responseCode":401
}
@hohonuuli
Copy link
Member

@dingosky This is currently a deliberate choice. ReadOnly users won't have access to any of the editing functions in the Oni service. Note that JWT tokens are only required for editing functions; GET endpoints do not require any authentication ATM.

See JwtService.scala#78

@hohonuuli
Copy link
Member

mbari-org/oni 3a24411

@hohonuuli
Copy link
Member

I've clarified the 401 response. ReadOnly users that attempt to login will get:

{
  "message":"Unable to login. Check your username and password and verify that you are an administrator or maintainer",
  "responseCode":401
}

@dingosky
Copy link
Collaborator Author

dingosky commented Feb 6, 2025

My misunderstanding. So I believe this means the login form should include a "Read Only" option that allows UI access without credentials. I have the Read Only gating factor in the code, just didn't understand that Read Only user wasn't a registered user with a ReadOnly role.

@dingosky dingosky closed this as completed Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants