WIP: Authenticate

This commit is contained in:
Philipp Wolfer 2023-11-21 08:51:47 +01:00
parent 3d3685d8bc
commit 94704f9cd0
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
5 changed files with 126 additions and 20 deletions

View file

@ -35,15 +35,6 @@ type Backend interface {
FromConfig(config *viper.Viper) Backend
}
type OAuth2Backend interface {
Backend
// Returns OAuth2 config suitable for this backend
OAuth2Config(redirectUrl string) oauth2.Config
// Setup the OAuth2 client
OAuth2Setup(redirectUrl string, token *oauth2.Token) error
}
type ImportBackend interface {
Backend
@ -91,3 +82,12 @@ type LovesImport interface {
// Imports the given list of loves.
ImportLoves(export LovesResult, importResult ImportResult, progress chan Progress) (ImportResult, error)
}
// Must be implemented by backends requiring OAuth2 authentication
type OAuth2Authenticator interface {
// Returns OAuth2 config suitable for this backend
OAuth2Config(redirectUrl string) oauth2.Config
// Setup the OAuth2 client
OAuth2Setup(redirectUrl string, token *oauth2.Token) error
}