provider.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package oauth2 // import "miniflux.app/v2/internal/oauth2"
  4. import (
  5. "context"
  6. "golang.org/x/oauth2"
  7. "miniflux.app/v2/internal/model"
  8. )
  9. // Provider defines the interface that all OAuth2 providers must implement.
  10. type Provider interface {
  11. // Config returns the OAuth2 configuration for this provider.
  12. Config() *oauth2.Config
  13. // UserExtraKey returns the key used to store the provider-specific user ID.
  14. UserExtraKey() string
  15. // Profile exchanges the authorization code for a token and fetches the user's profile.
  16. Profile(ctx context.Context, code, codeVerifier string) (*UserProfile, error)
  17. // PopulateUserCreationWithProfileID sets the provider-specific ID on a new user creation request.
  18. PopulateUserCreationWithProfileID(user *model.UserCreationRequest, profile *UserProfile)
  19. // PopulateUserWithProfileID sets the provider-specific ID on an existing user.
  20. PopulateUserWithProfileID(user *model.User, profile *UserProfile)
  21. // UserProfileID returns the provider-specific ID from the given user.
  22. UserProfileID(user *model.User) string
  23. // UnsetUserProfileID removes the provider-specific ID from the given user.
  24. UnsetUserProfileID(user *model.User)
  25. }