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/v1/users/[:user]/tokens is too special. Make it less special? #4315

Closed
6 tasks
kainz opened this issue Jun 25, 2018 · 4 comments
Closed
6 tasks

api/v1/users/[:user]/tokens is too special. Make it less special? #4315

kainz opened this issue Jun 25, 2018 · 4 comments
Labels
modifies/api This PR adds API routes or modifies them type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@kainz
Copy link

kainz commented Jun 25, 2018

  • Gitea version (or commit ref): v1.4.2, master
  • Git version: N/A
  • Operating system: Linux
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • [ X ] Not relevant
  • Log gist:

Description

If you are using gitea with any auth which disables basic user/pw login, the tokens API is effectively disabled. This breaks drone (and other token-handling) integrations if you are using anything but direct username/pw auth. See at least #2743, and #3843.

As is mentioned in #3843, the implementation of /tokens uses a couple hacks to minimize its logic, it only allows usage if a the call is authenticated through BasicAuth, and it also ignores the :user argument, only accessing tokens for the authenticated user.

If you are trying to build a system around gitea using any external login provider, this pretty much breaks all integrations.

A longer term fix for this sort of setup is probably having a full oauth consumer / ask for permissons workflow etc, but as a shorter term fix, I propose implementing the following:

  1. Provide a configuration option to allow admin users to edit (add/remove) other users' tokens.
  2. Provide a configuration option to toggle between the current 'safe?' behavior of the current tokens API, or allow the tokens API to be used from other login sources.

Related to these, there's another question to answer I think: in the presence of a token vs alternate auth (reverse proxy web header, oauth bearer etc), should the priority of those be configurable? Does it matter? Is there a long term authentication roadmap for Gitea?

I have the beginnings of a fix for number 2 here that I need to use Drone in my current org's setup (Mutual TLS auth everywhere), and think I have a good idea for basically doing 1, but I want to float the idea of mergability of these features.

Thoughts?

@techknowlogick techknowlogick added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Jun 25, 2018
@tarelda
Copy link
Contributor

tarelda commented Jun 26, 2018

I think it should be done with #27 and build around it.
Btw as I suggested in #4288 auth module is currently pile of garbage that needs major refactor and separation of concerns.

@TheTechArch
Copy link

We have the same need. Trying to integrate another plattform we are now forced to ask the user to generate token in GUI so we can store in other part of application. We want to generate tokens based on logged inn users session. (same as the other apis)

@XPlantefeve
Copy link

I had a similar need (token creation automation) and after a few tests, I noticed that it can be done through the API with an administrator using basic authentication and sudoing as the user.

Obviously, it raises other issues (the admin user password has to be stored), but I plan to work around that block by setting a cron to watch users creation and create tokens centrally.

@6543 6543 added the modifies/api This PR adds API routes or modifies them label Sep 17, 2020
@6543
Copy link
Member

6543 commented Sep 21, 2020

token created by token is not the best way ...
if we have a right system to create token with different rights we can do this.

for now BasicAuth either via Admin or user credentials itselve has to be used

I'll close this issue since it is very old and if there is a specific problem a issue who describe it more exact should be created

@6543 6543 closed this as completed Sep 21, 2020
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
modifies/api This PR adds API routes or modifies them type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

6 participants