diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-07-05 13:17:24 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-07-05 13:17:24 +0200 |
| commit | 1865b016d0cca74cd3703db5a3b4217917988dec (patch) | |
| tree | 3da84dbc4f1ad49221c25fb83f402d27deb34138 /internal/oauth | |
| parent | e39b9a8a405fa8e5f73c32bb03a3f349f7f9f92d (diff) | |
Refactor: Handling of different servers and identifiers
- Uses OrgID for Secure Internet and gets the data from discovery
- Uses URL for Institute/Custom and gets the data from discovery
- Implements SKIP WAYF as we now have the needed data
- Implements an initial change location with a default location (NL right now)
Diffstat (limited to 'internal/oauth')
| -rw-r--r-- | internal/oauth/oauth.go | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go index 824db90..ef1bed4 100644 --- a/internal/oauth/oauth.go +++ b/internal/oauth/oauth.go @@ -223,11 +223,6 @@ func (oauth *OAuth) Callback(w http.ResponseWriter, req *http.Request) { } } -func (oauth *OAuth) Update(fsm *fsm.FSM, logger *log.FileLogger) { - oauth.FSM = fsm - oauth.Logger = logger -} - func (oauth *OAuth) Init(baseAuthorizationURL string, tokenURL string, fsm *fsm.FSM, logger *log.FileLogger) { oauth.BaseAuthorizationURL = baseAuthorizationURL oauth.TokenURL = tokenURL @@ -236,7 +231,7 @@ func (oauth *OAuth) Init(baseAuthorizationURL string, tokenURL string, fsm *fsm. } // Starts the OAuth exchange for eduvpn. -func (oauth *OAuth) start(name string) error { +func (oauth *OAuth) start(name string, postprocessAuth func(string) string) error { errorMessage := "failed starting OAuth exchange" if !oauth.FSM.HasTransition(fsm.OAUTH_STARTED) { return &types.WrappedErrorMessage{Message: errorMessage, Err: fsm.WrongStateTransitionError{Got: oauth.FSM.Current, Want: fsm.OAUTH_STARTED}.CustomError()} @@ -274,7 +269,7 @@ func (oauth *OAuth) start(name string) error { oauthSession := OAuthExchangeSession{ClientID: name, State: state, Verifier: verifier} oauth.Session = oauthSession // Run the state callback in the background so that the user can login while we start the callback server - oauth.FSM.GoTransitionWithData(fsm.OAUTH_STARTED, authURL, true) + oauth.FSM.GoTransitionWithData(fsm.OAUTH_STARTED, postprocessAuth(authURL), true) return nil } @@ -298,9 +293,9 @@ func (oauth *OAuth) Cancel() { oauth.Session.Server.Shutdown(oauth.Session.Context) } -func (oauth *OAuth) Login(name string) error { +func (oauth *OAuth) Login(name string, postprocessAuth func(string) string) error { errorMessage := "failed OAuth login" - authInitializeErr := oauth.start(name) + authInitializeErr := oauth.start(name, postprocessAuth) if authInitializeErr != nil { return &types.WrappedErrorMessage{Message: errorMessage, Err: authInitializeErr} |
