aboutsummaryrefslogtreecommitdiffstats
path: root/services/auth/source/oauth2/init.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/auth/source/oauth2/init.go')
-rw-r--r--services/auth/source/oauth2/init.go25
1 files changed, 7 insertions, 18 deletions
diff --git a/services/auth/source/oauth2/init.go b/services/auth/source/oauth2/init.go
index 343b24cf6f..edbbb8969e 100644
--- a/services/auth/source/oauth2/init.go
+++ b/services/auth/source/oauth2/init.go
@@ -5,23 +5,21 @@
package oauth2
import (
+ "encoding/gob"
"net/http"
"sync"
- "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/login"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"github.com/google/uuid"
+ "github.com/gorilla/sessions"
"github.com/markbates/goth/gothic"
)
var gothRWMutex = sync.RWMutex{}
-// SessionTableName is the table name that OAuth2 will use to store things
-const SessionTableName = "oauth2_session"
-
// UsersStoreKey is the key for the store
const UsersStoreKey = "gitea-oauth2-sessions"
@@ -34,23 +32,14 @@ func Init() error {
return err
}
- store, err := db.CreateStore(SessionTableName, UsersStoreKey)
- if err != nil {
- return err
- }
-
- // according to the Goth lib:
- // set the maxLength of the cookies stored on the disk to a larger number to prevent issues with:
- // securecookie: the value is too long
- // 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(setting.OAuth2.MaxTokenLength)
-
// Lock our mutex
gothRWMutex.Lock()
- gothic.Store = store
+ gob.Register(&sessions.Session{})
+
+ gothic.Store = &SessionsStore{
+ maxLength: int64(setting.OAuth2.MaxTokenLength),
+ }
gothic.SetState = func(req *http.Request) string {
return uuid.New().String()