Allow administrators to create tokens for other users #7382

Closed
opened 2025-11-02 07:24:29 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @djcaesar9114 on GitHub (May 25, 2021).

It's more a feature request than a bug report

  • Gitea version (or commit ref): 1.15.0+dev-344-g5285a3e70 built with GNU Make 4.3, go1.16.4 : bindata, timetzdata, sqlite, sqlite_unlock_notify
  • Git version: 2.25.1
  • Operating system: Ubuntu 20.04

Gitea on docker

  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist: useless

Description

I'm using a SSO to handle connections on my apps. I don't have the hand on this SSO so I can't integrate my Gitea instance in this SSO. What I would like is to allow the users of my app to post issues on the gitea with their userID.

I started to develop this mechanism:

  • check if the username exists: GET /users/<username>
  • if it doesn't exist, create it: POST /admin/users
  • get the tokens of the user: GET /users/<username>/tokens
  • if in the list of tokens I don't have a "myapp" token, I create it: POST /users/<username>/tokens
  • with the token, I create the issue

The problem is that I can't create a token for another user, it has to be the user connected who creates his own token. I could create the same password for all my users, but it's not secure at all and I'd like my users to be able to connect to Gitea with their own password.

Would it be possible to allow administrators to create tokens for other users?

Screenshots

Useless

Originally created by @djcaesar9114 on GitHub (May 25, 2021). ### It's more a feature request than a bug report - Gitea version (or commit ref): 1.15.0+dev-344-g5285a3e70 built with GNU Make 4.3, go1.16.4 : bindata, timetzdata, sqlite, sqlite_unlock_notify - Git version: 2.25.1 - Operating system: Ubuntu 20.04 Gitea on docker - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [X] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [X] No - Log gist: useless ## Description I'm using a SSO to handle connections on my apps. I don't have the hand on this SSO so I can't integrate my Gitea instance in this SSO. What I would like is to allow the users of my app to post issues on the gitea with their userID. I started to develop this mechanism: - check if the username exists: GET /users/\<username\> - if it doesn't exist, create it: POST /admin/users - get the tokens of the user: GET /users/\<username\>/tokens - if in the list of tokens I don't have a "myapp" token, I create it: POST /users/\<username\>/tokens - with the token, I create the issue The problem is that I can't create a token for another user, it has to be the user connected who creates his own token. I could create the same password for all my users, but it's not secure at all and I'd like my users to be able to connect to Gitea with their own password. Would it be possible to allow administrators to create tokens for other users? ## Screenshots Useless
GiteaMirror added the type/proposal label 2025-11-02 07:24:29 -06:00
Author
Owner

@lunny commented on GitHub (May 31, 2021):

We have su feature, so this is unnecessary.

@lunny commented on GitHub (May 31, 2021): We have su feature, so this is unnecessary.
Author
Owner

@techknowlogick commented on GitHub (May 31, 2021):

Closing, as you can use the sudo header per https://docs.gitea.io/en-us/api-usage/#sudo to impersonate other users.

@techknowlogick commented on GitHub (May 31, 2021): Closing, as you can use the `sudo` header per https://docs.gitea.io/en-us/api-usage/#sudo to impersonate other users.
Author
Owner

@djcaesar9114 commented on GitHub (Jun 3, 2021):

OK but an explanation in the documention on how sudo works with Gitea API wouldn't be useless...

@djcaesar9114 commented on GitHub (Jun 3, 2021): OK but an explanation in the documention on how sudo works with Gitea API wouldn't be useless...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7382