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

API ignores basic auth (for creating API key) #25503

Closed
lonix1 opened this issue Jun 25, 2023 · 3 comments
Closed

API ignores basic auth (for creating API key) #25503

lonix1 opened this issue Jun 25, 2023 · 3 comments
Labels

Comments

@lonix1
Copy link
Contributor

lonix1 commented Jun 25, 2023

Description

I am using ansible to provision a gitea server and configure it. I created an admin account using the CLI.

There are some things that can only be done with the API, but to use it one needs an API key. And I can't do that manually - I want to automate that.

So using basic auth, I tried:

curl -X POST \
  'http://localhost:3000/api/v1/users/username/tokens' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -u username:password \
  -d '{ "name": "hello" }'

Error:

Only signed in user is allowed to call APIs.

So I tried in the swagger interface. In the auth popup I entered username/password for the basic auth option, then I tried the endpoint. Result:

Only signed in user is allowed to call APIs.

I double checked my syntax with the docs here, and it seems correct. And my username/password is correct as I use it in the gitea frontend.

Gitea Version

1.20.0-rc2

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

linux

How are you running Gitea?

docker rootful

Database

SQLite

@lonix1
Copy link
Contributor Author

lonix1 commented Jun 25, 2023

This is not documented, but is possible via the CLI:

$ gitea admin user generate-access-token --username username --token-name hello

Thanks to @delvh for letting me know in the discord chat!

@lonix1 lonix1 closed this as completed Jun 25, 2023
@delvh
Copy link
Member

delvh commented Jun 25, 2023

By the way, docs PR are always welcome, if you want to improve the documentation.

@lonix1
Copy link
Contributor Author

lonix1 commented Jun 25, 2023

LOL - I just submitted a PR, this second! #25504

techknowlogick pushed a commit that referenced this issue Jun 26, 2023
Related to #25503

---------

Co-authored-by: delvh <dev.lh@web.de>
techknowlogick pushed a commit to techknowlogick/gitea that referenced this issue Jun 26, 2023
Related to go-gitea#25503

---------

Co-authored-by: delvh <dev.lh@web.de>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants