Skip to content

Commit 0c1ff24

Browse files
KN4CK3RAbdulrhmnGhanem
authored andcommitted
Use data path instead of config path (go-gitea#16227)
1 parent 9149383 commit 0c1ff24

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

custom/conf/app.example.ini

+10-1
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,17 @@ INTERNAL_TOKEN=
388388
;; Enables OAuth2 provider
389389
ENABLE = true
390390
;;
391+
;; Algorithm used to sign OAuth2 tokens. Valid values: HS256, HS384, HS512, RS256, RS384, RS512, ES256, ES384, ES512
392+
;JWT_SIGNING_ALGORITHM = RS256
393+
;;
394+
;; Private key file path used to sign OAuth2 tokens. The path is relative to APP_DATA_PATH.
395+
;; This setting is only needed if JWT_SIGNING_ALGORITHM is set to RS256, RS384, RS512, ES256, ES384 or ES512.
396+
;; The file must contain a RSA or ECDSA private key in the PKCS8 format. If no key exists a 4096 bit key will be created for you.
397+
;JWT_SIGNING_PRIVATE_KEY_FILE = jwt/private.pem
398+
;;
391399
;; OAuth2 authentication secret for access and refresh tokens, change this yourself to a unique string. CLI generate option is helpful in this case. https://docs.gitea.io/en-us/command-line/#generate
392-
JWT_SECRET =
400+
;; This setting is only needed if JWT_SIGNING_ALGORITHM is set to HS256, HS384 or HS512.
401+
;JWT_SECRET =
393402
;;
394403
;; Lifetime of an OAuth2 access token in seconds
395404
;ACCESS_TOKEN_EXPIRATION_TIME = 3600

docs/content/doc/advanced/config-cheat-sheet.en-us.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take ef
861861
- `INVALIDATE_REFRESH_TOKENS`: **false**: Check if refresh token has already been used
862862
- `JWT_SIGNING_ALGORITHM`: **RS256**: Algorithm used to sign OAuth2 tokens. Valid values: \[`HS256`, `HS384`, `HS512`, `RS256`, `RS384`, `RS512`, `ES256`, `ES384`, `ES512`\]
863863
- `JWT_SECRET`: **\<empty\>**: OAuth2 authentication secret for access and refresh tokens, change this to a unique string. This setting is only needed if `JWT_SIGNING_ALGORITHM` is set to `HS256`, `HS384` or `HS512`.
864-
- `JWT_SIGNING_PRIVATE_KEY_FILE`: **jwt/private.pem**: Private key file path used to sign OAuth2 tokens. The path is relative to `CUSTOM_PATH`. This setting is only needed if `JWT_SIGNING_ALGORITHM` is set to `RS256`, `RS384`, `RS512`, `ES256`, `ES384` or `ES512`. The file must contain a RSA or ECDSA private key in the PKCS8 format.
864+
- `JWT_SIGNING_PRIVATE_KEY_FILE`: **jwt/private.pem**: Private key file path used to sign OAuth2 tokens. The path is relative to `APP_DATA_PATH`. This setting is only needed if `JWT_SIGNING_ALGORITHM` is set to `RS256`, `RS384`, `RS512`, `ES256`, `ES384` or `ES512`. The file must contain a RSA or ECDSA private key in the PKCS8 format. If no key exists a 4096 bit key will be created for you.
865865
- `MAX_TOKEN_LENGTH`: **32767**: Maximum length of token/cookie to accept from OAuth2 provider
866866

867867
## i18n (`i18n`)

modules/setting/setting.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ func NewContext() {
805805
}
806806

807807
if !filepath.IsAbs(OAuth2.JWTSigningPrivateKeyFile) {
808-
OAuth2.JWTSigningPrivateKeyFile = filepath.Join(CustomPath, OAuth2.JWTSigningPrivateKeyFile)
808+
OAuth2.JWTSigningPrivateKeyFile = filepath.Join(AppDataPath, OAuth2.JWTSigningPrivateKeyFile)
809809
}
810810

811811
sec = Cfg.Section("admin")

0 commit comments

Comments
 (0)