loadOrCreateAsymmetricKey called when oauth2 is disabled #12778

Closed
opened 2025-11-02 10:20:44 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @pboguslawski on GitHub (Apr 3, 2024).

Description

When oauth2 is disabled in config with

[oauth2]
ENABLE = false

gitea is still trying to generate private key using jwtsigningkey.go:386:loadOrCreateAsymmetricKey(). Shouldn't oauth2.Init be skipped in this scenario?

Gitea Version

1.21.10

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

compiled from sources

Database

MySQL/MariaDB

Originally created by @pboguslawski on GitHub (Apr 3, 2024). ### Description When oauth2 is disabled in config with ``` [oauth2] ENABLE = false ``` gitea is still trying to generate private key using jwtsigningkey.go:386:loadOrCreateAsymmetricKey(). Shouldn't [`oauth2.Init`](https://github.com/go-gitea/gitea/blob/1195be41a13d2198ab644c8558549edd74485510/routers/init.go#L140) be skipped in this scenario? ### Gitea Version 1.21.10 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? compiled from sources ### Database MySQL/MariaDB
GiteaMirror added the type/bug label 2025-11-02 10:20:44 -06:00
Author
Owner

@lunny commented on GitHub (Apr 3, 2024):

I think some codes mixed Gitea as OAuth2 provider and Gitea as OAuth2 client.

@lunny commented on GitHub (Apr 3, 2024): I think some codes mixed Gitea as OAuth2 provider and Gitea as OAuth2 client.
Author
Owner

@hawicz commented on GitHub (Jul 1, 2024):

It also creates the private key in the wrong path. Here's a patch that fixes both of those problems
oauth_init.patch

@hawicz commented on GitHub (Jul 1, 2024): It also creates the private key in the wrong path. Here's a patch that fixes both of those problems [oauth_init.patch](https://github.com/user-attachments/files/16054350/oauth_init.patch)
Author
Owner

@techknowlogick commented on GitHub (Jul 1, 2024):

Thanks @hawicz, I'm creating a PR with your patch. In the mainline branch the second part is caught prior to the load here: https://github.com/go-gitea/gitea/blob/main/modules/setting/oauth2.go#L129-L131 and in 1.22 too.

@techknowlogick commented on GitHub (Jul 1, 2024): Thanks @hawicz, I'm creating a PR with your patch. In the mainline branch the second part is caught prior to the load here: https://github.com/go-gitea/gitea/blob/main/modules/setting/oauth2.go#L129-L131 and in 1.22 too.
Author
Owner

@lunny commented on GitHub (Sep 27, 2024):

It also creates the private key in the wrong path. Here's a patch that fixes both of those problems oauth_init.patch

I cannot reproduce the error that the private.key in the wrong place.

@lunny commented on GitHub (Sep 27, 2024): > It also creates the private key in the wrong path. Here's a patch that fixes both of those problems [oauth_init.patch](https://github.com/user-attachments/files/16054350/oauth_init.patch) I cannot reproduce the error that the private.key in the wrong place.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#12778