Skip to content

Instantly share code, notes, and snippets.

@kousu

kousu/POST.md Secret

Created October 5, 2022 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kousu/22400726677a1b8fe62b976807a33935 to your computer and use it in GitHub Desktop.
Save kousu/22400726677a1b8fe62b976807a33935 to your computer and use it in GitHub Desktop.
Gitea and Multiple Users

(in reply to: https://community.harness.io/t/gitea-and-multiple-users/10225 ; I don't have enough reputation to post this whole thing there yet)

Since you must have DRONE_GITEA_CLIENT_ID/DRONE_GITEA_CLIENT_SECRET, and Gitea only allows OAuth to be attached to users, I solved it by creating a puppet ci-admin account in Gitea, at https://data.dev.neuropoly.org/ci-admin. My deployment script scrambles and throws away its password once finished, and marks ci-admin as non-admin and unable to log in.

Within that account's settings, at https://data.dev.neuropoly.org/user/settings/applications, the connection to Drone looks like

Screenshot 2022-10-05 at 17-00-42 Neurogitea

(for what it's worth I set that up via Gitea's API -- today is the first time I've ever bothered to look at Drone's OAuth credentials on the web)

The upshot is that when someone logs in they see

Screenshot 2022-10-05 at 17-03-12 Drone CI

Screenshot 2022-10-05 at 17-03-19 Neurogitea

If they click the "@ci-admin" link they see this profile page explaining

Screenshot 2022-10-05 at 16-52-56 DroneCI Administrator

(but I don't expect anyone will ever click that)

And yes anyone logging in with this can access all their own repositories, even while ci-admin cannot:

Screenshot 2022-10-05 at 17-10-33 Drone CI

The OAuth for sign-in has nothing to do with the OAuth for repositories. When someone signs in to Drone via Gitea, Gitea sends an OAuth token to Drone that grants access to whatever the signing in user can see. If I sign in as ci-admin I see nothing:

Screenshot 2022-10-05 at 17-14-49 Drone CI

I suppose, in theory, a malicious user could deploy a modified Drone that relays all the OAuth tokens to them. That's the risk people take whenever they click that big red "Authorize Application" button. But Drone as it exists protects those credentials.

tl;dr: make a dummy user in Gitea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment