diff --git a/internal/backends/tokensource.go b/internal/auth/tokensource.go similarity index 99% rename from internal/backends/tokensource.go rename to internal/auth/tokensource.go index 6dfc184..626f3c4 100644 --- a/internal/backends/tokensource.go +++ b/internal/auth/tokensource.go @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with Scotty. If not, see . */ -package backends +package auth import ( "context" diff --git a/internal/backends/auth.go b/internal/backends/auth.go index 5bca84c..49584ec 100644 --- a/internal/backends/auth.go +++ b/internal/backends/auth.go @@ -22,6 +22,7 @@ import ( "strings" "github.com/spf13/viper" + "go.uploadedlobster.com/scotty/internal/auth" "go.uploadedlobster.com/scotty/internal/models" "go.uploadedlobster.com/scotty/internal/storage" ) @@ -36,19 +37,19 @@ func BuildRedirectURL(config *viper.Viper, backend string) (*url.URL, error) { } func Authenticate(service string, backend models.Backend, db storage.Database, config *viper.Viper) (bool, error) { - authenticator, auth := backend.(models.OAuth2Authenticator) - if auth { + authenticator, needAuth := backend.(models.OAuth2Authenticator) + if needAuth { redirectURL, err := BuildRedirectURL(config, backend.Name()) if err != nil { - return auth, err + return needAuth, err } token, err := db.GetOAuth2Token(service) if err != nil { - return auth, err + return needAuth, err } conf := authenticator.OAuth2Strategy(redirectURL).Config() - tokenSource := NewDatabaseTokenSource(db, service, &conf, token) + tokenSource := auth.NewDatabaseTokenSource(db, service, &conf, token) authenticator.OAuth2Setup(tokenSource) } - return auth, nil + return needAuth, nil }