Enable X-Gitea-OTP header for git operations #12399

Closed
opened 2025-11-02 10:08:37 -06:00 by GiteaMirror · 12 comments
Owner

Originally created by @Kwonunn on GitHub (Jan 28, 2024).

Feature Description

Currently, users with Multi-Factor Auth can't use http/https to perform git operations. The Gitea API does support sending the OTP along using the X-Gitea-OTP header. It would be useful if git operations also supported this header.

It is possible to add custom headers to git http requests using the -c http.extraHeaders="X-Gitea-OTP: 123456" flag.

This would be useful for one-time cloning of projects to computers where we don't want to set up our entire SSH key, and is a lot easier than creating an application token for the operation.

Screenshots

No response

Originally created by @Kwonunn on GitHub (Jan 28, 2024). ### Feature Description Currently, users with Multi-Factor Auth can't use http/https to perform git operations. The Gitea API does support sending the OTP along using the X-Gitea-OTP header. It would be useful if git operations also supported this header. It is possible to add custom headers to git http requests using the `-c http.extraHeaders="X-Gitea-OTP: 123456"` flag. This would be useful for one-time cloning of projects to computers where we don't want to set up our entire SSH key, and is a lot easier than creating an application token for the operation. ### Screenshots _No response_
GiteaMirror added the type/proposal label 2025-11-02 10:08:37 -06:00
Author
Owner

@KN4CK3R commented on GitHub (Jan 28, 2024):

That sounds really exhausting because the OTP always needs to be refreshed. Why not use a PAT instead of the normal password?

@KN4CK3R commented on GitHub (Jan 28, 2024): That sounds really exhausting because the OTP always needs to be refreshed. Why not use a PAT instead of the normal password?
Author
Owner

@Kwonunn commented on GitHub (Jan 28, 2024):

This is just for use in cases where I'm fetching a project once onto a server I don't want to set up SSH on.

Using tokens for this would either require making a fresh token every time which is annoying, or having one to always use which is a security hole.

@Kwonunn commented on GitHub (Jan 28, 2024): This is just for use in cases where I'm fetching a project once onto a server I don't want to set up SSH on. Using tokens for this would either require making a fresh token every time which is annoying, or having one to always use which is a security hole.
Author
Owner

@techknowlogick commented on GitHub (Jan 28, 2024):

This is quite interesting. On one hand user/pass auth for api/git operations are being depreciated, but it does give the idea of otp with scoped tokens 🤔

@techknowlogick commented on GitHub (Jan 28, 2024): This is quite interesting. On one hand user/pass auth for api/git operations are being depreciated, but it does give the idea of otp with scoped tokens 🤔
Author
Owner

@Kwonunn commented on GitHub (Jan 28, 2024):

Is Gitea planning to deprecate http entirely for git operations?

@Kwonunn commented on GitHub (Jan 28, 2024): Is Gitea planning to deprecate http entirely for git operations?
Author
Owner

@KN4CK3R commented on GitHub (Jan 28, 2024):

No, only the combination with username and password.

@KN4CK3R commented on GitHub (Jan 28, 2024): No, only the combination with username and password.
Author
Owner

@Kwonunn commented on GitHub (Jan 28, 2024):

Why, if I may ask? I know GitHub has stopped allowing it but I'm not quite sure why.

@Kwonunn commented on GitHub (Jan 28, 2024): Why, if I may ask? I know GitHub has stopped allowing it but I'm not quite sure why.
Author
Owner

@KN4CK3R commented on GitHub (Jan 28, 2024):

Because the username/password combination should be used in less places in favor of configurable tokens.

@KN4CK3R commented on GitHub (Jan 28, 2024): Because the username/password combination should be used in less places in favor of configurable tokens.
Author
Owner

@Kwonunn commented on GitHub (Jan 28, 2024):

I see. Then, perhaps another method is more appropriate.

Maybe we could add a quick token button in this menu
image
which would generate a temporary personal access token scoped specifically to that repository and with read-only access, which you could use once to clone the repository somewhere?

@Kwonunn commented on GitHub (Jan 28, 2024): I see. Then, perhaps another method is more appropriate. Maybe we could add a quick token button in this menu ![image](https://github.com/go-gitea/gitea/assets/39026963/570705a9-4a12-409a-b9dd-cd9fad6b8528) which would generate a temporary personal access token scoped specifically to that repository and with read-only access, which you could use once to clone the repository somewhere?
Author
Owner

@JakobDev commented on GitHub (Jan 29, 2024):

No, only the combination with username and password.

Why?

@JakobDev commented on GitHub (Jan 29, 2024): > No, only the combination with username and password. Why?
Author
Owner
@KN4CK3R commented on GitHub (Jan 29, 2024): > > No, only the combination with username and password. > > Why? https://github.com/go-gitea/gitea/issues/28968#issuecomment-1913668160 https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/#background
Author
Owner

@Kwonunn commented on GitHub (Jan 29, 2024):

I see. Then, perhaps another method is more appropriate.

Maybe we could add a quick token button in this menu image which would generate a temporary personal access token scoped specifically to that repository and with read-only access, which you could use once to clone the repository somewhere?

Should I make a new feature request for this new idea and just leave the http OTP thing?

@Kwonunn commented on GitHub (Jan 29, 2024): > I see. Then, perhaps another method is more appropriate. > > Maybe we could add a quick token button in this menu ![image](https://private-user-images.githubusercontent.com/39026963/300282460-570705a9-4a12-409a-b9dd-cd9fad6b8528.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDY1Mzg2NTYsIm5iZiI6MTcwNjUzODM1NiwicGF0aCI6Ii8zOTAyNjk2My8zMDAyODI0NjAtNTcwNzA1YTktNGExMi00MDlhLWI5ZGQtY2Q5ZmFkNmI4NTI4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAxMjklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMTI5VDE0MjU1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY2NGE2YjQ1OGU2YjQxMTQ5OTkzOWMzMWE1OWI4YzkzYThlZWE5Y2QxZjg1YmRhMmZjODA2ZTU3YjgzNTZmMWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.bvSZnHiSeob3TXqyKtw4-AEcnagzLLW6LKZgru6tTUg) which would generate a temporary personal access token scoped specifically to that repository and with read-only access, which you could use once to clone the repository somewhere? Should I make a new feature request for this new idea and just leave the http OTP thing?
Author
Owner

@JakobDev commented on GitHub (Jan 29, 2024):

Not beeing able to use Username/Password could be a problem for one time contributors

@JakobDev commented on GitHub (Jan 29, 2024): Not beeing able to use Username/Password could be a problem for one time contributors
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#12399