mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Add option to increase provided OAuth2 token maximum size (#11180)
Some OAuth2 providers return quite large structured tokens >32767 bytes. Gitea currently has a fixed maximum of 32767 bytes for these and unfortunately due to the convoluted nature of the dependent libraries the error returned is rather opaque. Here we manage the error a little better - detecting the rather opaque github.com/gorilla/securecookie.errEncodedValueTooLong and converting it to a more readable error. Further we provide a configurable option to increase the maximum size of the provided OAuth2 tokens. Fix #9907 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
		| @@ -5,7 +5,6 @@ | ||||
| package oauth2 | ||||
|  | ||||
| import ( | ||||
| 	"math" | ||||
| 	"net/http" | ||||
|  | ||||
| 	"code.gitea.io/gitea/modules/log" | ||||
| @@ -26,7 +25,7 @@ import ( | ||||
| 	"github.com/markbates/goth/providers/openidConnect" | ||||
| 	"github.com/markbates/goth/providers/twitter" | ||||
| 	"github.com/markbates/goth/providers/yandex" | ||||
| 	"github.com/satori/go.uuid" | ||||
| 	uuid "github.com/satori/go.uuid" | ||||
| 	"xorm.io/xorm" | ||||
| ) | ||||
|  | ||||
| @@ -58,7 +57,7 @@ func Init(x *xorm.Engine) error { | ||||
| 	// when using OpenID Connect , since this can contain a large amount of extra information in the id_token | ||||
|  | ||||
| 	// Note, when using the FilesystemStore only the session.ID is written to a browser cookie, so this is explicit for the storage on disk | ||||
| 	store.MaxLength(math.MaxInt16) | ||||
| 	store.MaxLength(setting.OAuth2.MaxTokenLength) | ||||
| 	gothic.Store = store | ||||
|  | ||||
| 	gothic.SetState = func(req *http.Request) string { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user