Running script that initialises a repository on a gitea server. But only some users on this server allowed to initialise repository.How Authorization

473 views Asked by At

I am running a powershell script, that makes a repository on a gitea server (using restAPI of gitea). But on the gitea server not everyone is allowed to initialise the repository, only some users are. How can I make my script authorize the permission that the current runner of the script has, and only then makes a repo?

the solution that I have thought till now: git uses access tokens to verify people when operations using the REST API are made. Anyone who wants to use my script will first have to make a token, then enter this token when running my script, and then my script will use this access token in the operation its doing.

Disadvantage: The user has to first make a token =(

Is there any other more elegant solution : like just directly entering the username and password. This way the user does not have to do anything new like making an access token just for my script and directly enter existing username and password which they use to enter the gitea server. Thank you for your time =)

1

There are 1 answers

0
VonC On

Your script could make a commit and a push (hence the need to enter username/password) to a public repository, where a post-receive hook would:

  • check if the user is authorized, for instance by checking if their username is part of a file managed independently on the Gitea server
  • make the REST API call with, as new repository name, the one mentioned in the commit message, as filled out by your script during the commit/push mentioned above.

In other words, the REST API call is not made on the client side, but on the server side, where an identity check can be done first.