Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging in with KeyCloak OpenID Connect: 500 error #9907

Closed
2 of 7 tasks
bestw opened this issue Jan 21, 2020 · 9 comments · Fixed by #11180
Closed
2 of 7 tasks

Logging in with KeyCloak OpenID Connect: 500 error #9907

bestw opened this issue Jan 21, 2020 · 9 comments · Fixed by #11180
Labels

Comments

@bestw
Copy link

bestw commented Jan 21, 2020

  • Gitea version (or commit ref):1.10.3 and 1.12.0+dev-135-g9bc841353
  • Git version:
  • Operating system: docker on Ubuntu 18.04
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

With logging in with OpenID Connect (KeyCloak 7.0.1 and 8.0.1), gitea returns a 500 Internal Server Error web.

And then we find when the first and last name of user in KeyCloak are both Chinese charactors, gitea returns a 500 error, and if not, gitea works with KeyCloak well.

We changed the version of gitea and keycloak, it always exists. We try to log in other apps with KeyCloak, it has no error.

Screenshots

@techknowlogick
Copy link
Member

Can you provide the log trace of the 500 error? Please see https://docs.gitea.io/en-us/logging-configuration/ for how to enable Trace log level.

@techknowlogick techknowlogick added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Jan 22, 2020
@jan0sch
Copy link

jan0sch commented Feb 3, 2020

I have the same kind of error using Jetbrains Hub as OpenID provider, logging in via "OpenID Connect" results in a 500 page and the following log line: [E] UserSignIn: could not find a matching session for this request

Here is a stack trace:

	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/routers/user/auth.go:588 (0x23b959a)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/routers/user/auth.go:583 (0x23b8730)
	/usr/local/go/src/reflect/value.go:460 (0x1592755)
	/usr/local/go/src/reflect/value.go:321 (0x1591f13)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:177 (0x1aaa4f9)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:137 (0x1aa9ea9)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:121 (0x1ad9838)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:112 (0x21cf7e1)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/modules/context/panic.go:39 (0x21cf7cd)
	/usr/local/go/src/reflect/value.go:460 (0x1592755)
	/usr/local/go/src/reflect/value.go:321 (0x1591f13)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:177 (0x1aaa4f9)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:137 (0x1aa9ea9)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:121 (0x1ad9838)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:112 (0x1ba6e45)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/session/session.go:192 (0x1ba6e30)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:79 (0x1ad96e0)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:157 (0x1aaa209)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:135 (0x1aa9f98)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:121 (0x1ad9838)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:112 (0x1aeaed9)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/recovery.go:161 (0x1aeaec7)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/logger.go:40 (0x1add3b3)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:157 (0x1aaa209)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:135 (0x1aa9f98)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:121 (0x1ad9838)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:112 (0x1aea210)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/logger.go:52 (0x1aea1fb)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/logger.go:40 (0x1add3b3)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:157 (0x1aaa209)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:135 (0x1aa9f98)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:121 (0x1ad9838)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/router.go:187 (0x1aec0f6)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/router.go:303 (0x1ae5ad5)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/macaron.go:220 (0x1ade74a)
	/wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/github.com/gorilla/context/context.go:141 (0x1d4485d)
	/usr/local/go/src/net/http/server.go:2007 (0x1856273)
	/usr/local/go/src/net/http/server.go:2802 (0x18596c3)
	/usr/local/go/src/net/http/server.go:1890 (0x1855064)
	/usr/local/go/src/runtime/asm_amd64.s:1357 (0x15620b0)
  • Gitea version: 1.10.3
  • Git version: 2.25.0
  • Operating system: FreeBSD 12.1-RELEASE-p2 GENERIC amd64
  • Database: PostgreSQL

I also discovered that if I clear the browser cache then another error is produced in the logs a bit before the matching session one:

[E] UserSignIn: securecookie: the value is too long
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/routers/user/auth.go:588 (0x23b959a)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/routers/user/auth.go:583 (0x23b8730)
        /usr/local/go/src/reflect/value.go:460 (0x1592755)
        /usr/local/go/src/reflect/value.go:321 (0x1591f13)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:177 (0x1aaa4f9)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:137 (0x1aa9ea9)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:121 (0x1ad9838)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:112 (0x21cf7e1)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/modules/context/panic.go:39 (0x21cf7cd)
        /usr/local/go/src/reflect/value.go:460 (0x1592755)
        /usr/local/go/src/reflect/value.go:321 (0x1591f13)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:177 (0x1aaa4f9)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:137 (0x1aa9ea9)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:121 (0x1ad9838)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:112 (0x1ba6e45)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/session/session.go:192 (0x1ba6e30)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:79 (0x1ad96e0)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:157 (0x1aaa209)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:135 (0x1aa9f98)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:121 (0x1ad9838)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:112 (0x1aeaed9)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/recovery.go:161 (0x1aeaec7)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/logger.go:40 (0x1add3b3)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:157 (0x1aaa209)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:135 (0x1aa9f98)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:121 (0x1ad9838)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:112 (0x1aea210)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/logger.go:52 (0x1aea1fb)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/logger.go:40 (0x1add3b3)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:157 (0x1aaa209)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/inject/inject.go:135 (0x1aa9f98)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/context.go:121 (0x1ad9838)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/router.go:187 (0x1aec0f6)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/router.go:303 (0x1ae5ad5)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/gitea.com/macaron/macaron/macaron.go:220 (0x1ade74a)
        /wrkdirs/usr/ports/www/gitea/work/gitea-1.10.3/vendor/github.com/gorilla/context/context.go:141 (0x1d4485d)
        /usr/local/go/src/net/http/server.go:2007 (0x1856273)
        /usr/local/go/src/net/http/server.go:2802 (0x18596c3)
        /usr/local/go/src/net/http/server.go:1890 (0x1855064)
        /usr/local/go/src/runtime/asm_amd64.s:1357 (0x15620b0)

I think that the [E] UserSignIn: securecookie: the value is too long one is the real cause of the error here.

Thank you very much for your effort.

King regards,

Jens

@lunny lunny added type/bug and removed issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail labels Feb 4, 2020
@knippers
Copy link

knippers commented Feb 7, 2020

I also get the UserSignIn: securecookie: the value is too long. We use JetBrains Hub as OpenID server. At one point in time it worked but I updated both Hub and Gitea at the same time so I don't know which one broke it. I have a workaround by using LDAP for now (which is fine).

@exit-code0
Copy link

exit-code0 commented Apr 6, 2020

Seeing the same issue when using Jetbrains Hub as OpenID server. After an update to Hub, some users are getting 500 errors when logging in, with this corresponding error in the Gitea logs:

routers/user/auth.go:588:handleOAuth2SignIn() [E] UserSignIn: securecookie: the value is too long

To work around this for the time being, we have removed custom avatars in Hub and replaced them with the default avatar to reduce the size of the cookie.

@jan0sch
Copy link

jan0sch commented Apr 22, 2020

I can confirm that disabling the avatar image or reducing the avatar image size on the Hub side is a workaround for this problem.

@zeripath
Copy link
Contributor

@jan0sch do you have an idea of how big these cookies get?

@zeripath
Copy link
Contributor

zeripath commented Apr 22, 2020

For those who wish to hack a solution quickly to this the problem appears to be:

store.MaxLength(math.MaxInt16)

Sets the maximum token/cookie length at 32767 - this needs to be increased to higher number - quite what though I'm uncertain.

@zeripath
Copy link
Contributor

zeripath commented Apr 22, 2020

To understand why that is the root cause of the problem is quite convoluted.

The error is a github.com/gorilla/securecookie.errEncodedValueTooLong it's ultimately returned from:

u, gothUser, err := oAuth2UserLoginCallback(loginSource, ctx.Req.Request, ctx.Resp)

That is:

gitea/routers/user/auth.go

Lines 667 to 708 in fcc8cdd

// OAuth2UserLoginCallback attempts to handle the callback from the OAuth2 provider and if successful
// login the user
func oAuth2UserLoginCallback(loginSource *models.LoginSource, request *http.Request, response http.ResponseWriter) (*models.User, goth.User, error) {
gothUser, err := oauth2.ProviderCallback(loginSource.Name, request, response)
if err != nil {
return nil, goth.User{}, err
}
user := &models.User{
LoginName: gothUser.UserID,
LoginType: models.LoginOAuth2,
LoginSource: loginSource.ID,
}
hasUser, err := models.GetUser(user)
if err != nil {
return nil, goth.User{}, err
}
if hasUser {
return user, gothUser, nil
}
// search in external linked users
externalLoginUser := &models.ExternalLoginUser{
ExternalID: gothUser.UserID,
LoginSourceID: loginSource.ID,
}
hasUser, err = models.GetExternalLogin(externalLoginUser)
if err != nil {
return nil, goth.User{}, err
}
if hasUser {
user, err = models.GetUserByID(externalLoginUser.UserID)
return user, gothUser, err
}
// no user found to login
return nil, gothUser, nil
}

In particular Line 670:

gothUser, err := oauth2.ProviderCallback(loginSource.Name, request, response)

That is:

// ProviderCallback handles OAuth callback, resolve to a goth user and send back to original url
// this will trigger a new authentication request, but because we save it in the session we can use that
func ProviderCallback(provider string, request *http.Request, response http.ResponseWriter) (goth.User, error) {
// not sure if goth is thread safe (?) when using multiple providers
request.Header.Set(providerHeaderKey, provider)
user, err := gothic.CompleteUserAuth(response, request)
if err != nil {
return user, err
}
return user, nil
}

In particular line 97 gothic.CompleteUserAuth is:

/*
CompleteUserAuth does what it says on the tin. It completes the authentication
process and fetches all of the basic information about the user from the provider.

It expects to be able to get the name of the provider from the query parameters
as either "provider" or ":provider".

See https://github.com/markbates/goth/examples/main.go to see this in action.
*/
var CompleteUserAuth = func(res http.ResponseWriter, req *http.Request) (goth.User, error) {
	defer Logout(res, req)
	if !keySet && defaultStore == Store {
		fmt.Println("goth/gothic: no SESSION_SECRET environment variable is set. The default cookie store is not available and any calls will fail. Ignore this warning if you are using a different store.")
	}

	providerName, err := GetProviderName(req)
	if err != nil {
		return goth.User{}, err
	}

	provider, err := goth.GetProvider(providerName)
	if err != nil {
		return goth.User{}, err
	}

	value, err := GetFromSession(providerName, req)
	if err != nil {
		return goth.User{}, err
	}

	sess, err := provider.UnmarshalSession(value)
	if err != nil {
		return goth.User{}, err
	}

	err = validateState(req, sess)
	if err != nil {
		return goth.User{}, err
	}

	user, err := provider.FetchUser(sess)
	if err == nil {
		// user can be found with existing session data
		return user, err
	}

	// get new token and retry fetch
	_, err = sess.Authorize(provider, req.URL.Query())
	if err != nil {
		return goth.User{}, err
	}

	err = StoreInSession(providerName, sess.Marshal(), req, res)

	if err != nil {
		return goth.User{}, err
	}

	gu, err := provider.FetchUser(sess)
	return gu, err
}

In particular StoreInSession(providerName, sess.Marshal(), req, res) is:

// StoreInSession stores a specified key/value pair in the session.
func StoreInSession(key string, value string, req *http.Request, res http.ResponseWriter) error {
	session, _ := Store.New(req, SessionName)

	if err := updateSessionValue(session, key, value); err != nil {
		return err
	}

	return session.Save(req, res)
}

And session.Save(req, res) is:

// Save is a convenience method to save this session. It is the same as calling
// store.Save(request, response, session). You should call Save before writing to
// the response or returning from the handler.
func (s *Session) Save(r *http.Request, w http.ResponseWriter) error {
	return s.store.Save(r, w, s)
}

with s.store.Save(r, w, s):

https://github.com/lafriks/xormstore/blob/d7ade16739923c5a2df7d0de8b9c7ebf6ad66826/xormstore.go#L150-L209

// Save session and set cookie header
func (st *Store) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error {
	s, _ := context.Get(r, contextKey(session.Name())).(*xormSession)

	// delete if max age is < 0
	if session.Options.MaxAge < 0 {
		if s != nil {
			if _, err := st.e.Delete(&xormSession{
				ID:        session.ID,
				tableName: st.opts.TableName,
			}); err != nil {
				return err
			}
		}
		http.SetCookie(w, sessions.NewCookie(session.Name(), "", session.Options))
		return nil
	}

	data, err := securecookie.EncodeMulti(session.Name(), session.Values, st.Codecs...)
	if err != nil {
		return err
	}
	now := util.TimeStampNow()
	expire := now.AddDuration(time.Second * time.Duration(session.Options.MaxAge))

	if s == nil {
		// generate random session ID key suitable for storage in the db
		session.ID = strings.TrimRight(
			base32.StdEncoding.EncodeToString(
				securecookie.GenerateRandomKey(sessionIDLen)), "=")
		s = &xormSession{
			ID:          session.ID,
			Data:        data,
			CreatedUnix: now,
			UpdatedUnix: now,
			ExpiresUnix: expire,
			tableName:   st.opts.TableName,
		}
		if _, err := st.e.Insert(s); err != nil {
			return err
		}
		context.Set(r, contextKey(session.Name()), s)
	} else {
		s.Data = data
		s.UpdatedUnix = now
		s.ExpiresUnix = expire
		if _, err := st.e.ID(s.ID).Cols("data", "updated_unix", "expires_unix").Update(s); err != nil {
			return err
		}
	}

	// set session id cookie
	id, err := securecookie.EncodeMulti(session.Name(), session.ID, st.Codecs...)
	if err != nil {
		return err
	}
	http.SetCookie(w, sessions.NewCookie(session.Name(), id, session.Options))

	return nil
}

Likely error is coming from:

	data, err := securecookie.EncodeMulti(session.Name(), session.Values, st.Codecs...)

but could be:

	id, err := securecookie.EncodeMulti(session.Name(), session.ID, st.Codecs...)

These both call:

// EncodeMulti encodes a cookie value using a group of codecs.
//
// The codecs are tried in order. Multiple codecs are accepted to allow
// key rotation.
//
// On error, may return a MultiError.
func EncodeMulti(name string, value interface{}, codecs ...Codec) (string, error) {
	if len(codecs) == 0 {
		return "", errNoCodecs
	}

	var errors MultiError
	for _, codec := range codecs {
		encoded, err := codec.Encode(name, value)
		if err == nil {
			return encoded, nil
		}
		errors = append(errors, err)
	}
	return "", errors
}

With the root error coming from encoded, err := codec.Encode(name, value) being:

// Encode encodes a cookie value.
//
// It serializes, optionally encrypts, signs with a message authentication code,
// and finally encodes the value.
//
// The name argument is the cookie name. It is stored with the encoded value.
// The value argument is the value to be encoded. It can be any value that can
// be encoded using the currently selected serializer; see SetSerializer().
//
// It is the client's responsibility to ensure that value, when encoded using
// the current serialization/encryption settings on s and then base64-encoded,
// is shorter than the maximum permissible length.
func (s *SecureCookie) Encode(name string, value interface{}) (string, error) {
	if s.err != nil {
		return "", s.err
	}
	if s.hashKey == nil {
		s.err = errHashKeyNotSet
		return "", s.err
	}
	var err error
	var b []byte
	// 1. Serialize.
	if b, err = s.sz.Serialize(value); err != nil {
		return "", cookieError{cause: err, typ: usageError}
	}
	// 2. Encrypt (optional).
	if s.block != nil {
		if b, err = encrypt(s.block, b); err != nil {
			return "", cookieError{cause: err, typ: usageError}
		}
	}
	b = encode(b)
	// 3. Create MAC for "name|date|value". Extra pipe to be used later.
	b = []byte(fmt.Sprintf("%s|%d|%s|", name, s.timestamp(), b))
	mac := createMac(hmac.New(s.hashFunc, s.hashKey), b[:len(b)-1])
	// Append mac, remove name.
	b = append(b, mac...)[len(name)+1:]
	// 4. Encode to base64.
	b = encode(b)
	// 5. Check length.
	if s.maxLength != 0 && len(b) > s.maxLength {
		return "", errEncodedValueTooLong
	}
	// Done.
	return string(b), nil
}

In particular:

		return "", errEncodedValueTooLong

zeripath added a commit to zeripath/gitea that referenced this issue Apr 22, 2020
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 go-gitea#9907

Signed-off-by: Andrew Thornton <[email protected]>
@jan0sch
Copy link

jan0sch commented Apr 22, 2020

I guess that the value can get quite large if the avatar image is sent (encoded) with it. I haven't measured though.

sapk pushed a commit that referenced this issue Apr 22, 2020
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 <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
ydelafollye pushed a commit to ydelafollye/gitea that referenced this issue Jul 31, 2020
…1180)

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 go-gitea#9907

Signed-off-by: Andrew Thornton <[email protected]>

Co-authored-by: techknowlogick <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants