Skip to content

Commit 6fd4303

Browse files
committed
hard code oauth2 app git-credential-oauth
1 parent f8bb101 commit 6fd4303

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

models/auth/oauth2.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,25 @@ func (app *OAuth2Application) CreateGrant(ctx context.Context, userID int64, sco
129129

130130
// GetOAuth2ApplicationByClientID returns the oauth2 application with the given client_id. Returns an error if not found.
131131
func GetOAuth2ApplicationByClientID(ctx context.Context, clientID string) (app *OAuth2Application, err error) {
132+
// the following Git credential helpers are universally useful
133+
// https://git-scm.com/doc/credential-helpers
134+
if clientID == "a4792ccc-144e-407e-86c9-5e7d8d9c3269" {
135+
return &OAuth2Application{
136+
Name: "git-credential-oauth",
137+
ClientID: "a4792ccc-144e-407e-86c9-5e7d8d9c3269",
138+
ConfidentialClient: false,
139+
RedirectURIs: []string{"http://127.0.0.1"},
140+
}, nil
141+
}
142+
if clientID == "e90ee53c-94e2-48ac-9358-a874fb9e0662" {
143+
return &OAuth2Application{
144+
Name: "Git Credential Manager",
145+
ClientID: "e90ee53c-94e2-48ac-9358-a874fb9e0662",
146+
ConfidentialClient: false,
147+
RedirectURIs: []string{"http://127.0.0.1"},
148+
}, nil
149+
}
150+
132151
app = new(OAuth2Application)
133152
has, err := db.GetEngine(ctx).Where("client_id = ?", clientID).Get(app)
134153
if !has {

routers/web/repo/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func httpBase(ctx *context.Context) *serviceHandler {
147147
// rely on the results of Contexter
148148
if !ctx.IsSigned {
149149
// TODO: support digit auth - which would be Authorization header with digit
150-
ctx.Resp.Header().Set("WWW-Authenticate", "Basic realm=\".\"")
150+
ctx.Resp.Header().Set("WWW-Authenticate", `Basic realm="Gitea"`)
151151
ctx.Error(http.StatusUnauthorized)
152152
return nil
153153
}

0 commit comments

Comments
 (0)