Skip to content

Commit

Permalink
[Patch] Add new interface FetchUserWithToken
Browse files Browse the repository at this point in the history
  • Loading branch information
althenlimzixuan committed Nov 19, 2024
1 parent ef9ee34 commit 71ca33a
Show file tree
Hide file tree
Showing 75 changed files with 356 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gothic/gothic.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,10 @@ func updateSessionValue(session *sessions.Session, key, value string) error {
session.Values[key] = b.String()
return nil
}

func FetchUserInfoWithToken(token string) (goth.User, error) {

result := goth.User{}

return result, nil
}
3 changes: 3 additions & 0 deletions provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ type Provider interface {
Debug(bool)
RefreshToken(refreshToken string) (*oauth2.Token, error) // Get new access token based on the refresh token
RefreshTokenAvailable() bool // Refresh token is provided by auth provider or not
// IsEmailProvided() bool
// IsPhoneProvided() bool
FetchUserWithToken(string) (User, error)
}

const NoAuthUrlErrorMessage = "an AuthURL has not been set"
Expand Down
5 changes: 5 additions & 0 deletions providers/amazon/amazon.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package amazon
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -165,3 +166,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
}
return newToken, err
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/apple/apple.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,8 @@ func (p *Provider) RevokeToken(token string) error {

return nil
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
//TODO:
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/auth0/auth0.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package auth0
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -181,3 +182,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
}
return newToken, err
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/azuread/azuread.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package azuread

import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -185,3 +186,7 @@ func userFromReader(r io.Reader, user *goth.User) error {
func authorizationHeader(session *Session) (string, string) {
return "Authorization", fmt.Sprintf("Bearer %s", session.AccessToken)
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/azureadv2/azureadv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package azureadv2

import (
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -231,3 +232,7 @@ func scopesToStrings(scopes ...ScopeType) []string {
}
return strs
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/battlenet/battlenet.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package battlenet
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -151,3 +152,7 @@ func (p *Provider) RefreshTokenAvailable() bool {
func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
return nil, nil
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/bitbucket/bitbucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package bitbucket
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -239,3 +240,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
}
return newToken, err
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
4 changes: 4 additions & 0 deletions providers/bitly/bitly.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,7 @@ func getEmail(emails []struct {

return "", fmt.Errorf("The user does not have a verified, primary email address on Bitly")
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/box/box.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package box

import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -156,3 +157,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
}
return newToken, err
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
4 changes: 4 additions & 0 deletions providers/classlink/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,7 @@ func newConfig(provider *Provider, scopes []string) *oauth2.Config {

return c
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/cloudfoundry/cf.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -175,3 +176,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
}
return newToken, err
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/cognito/cognito.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cognito
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -237,3 +238,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
}
return newToken, err
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/dailymotion/dailymotion.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package dailymotion
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -187,3 +188,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
}
return newToken, err
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
4 changes: 4 additions & 0 deletions providers/deezer/deezer.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,7 @@ func (p *Provider) RefreshTokenAvailable() bool {
func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
return nil, errors.New("Refresh token is not provided by deezer")
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/digitalocean/digitalocean.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package digitalocean
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -176,3 +177,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
}
return newToken, err
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package discord
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -235,3 +236,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
}
return newToken, err
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
4 changes: 4 additions & 0 deletions providers/dropbox/dropbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
func (p *Provider) RefreshTokenAvailable() bool {
return false
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/eveonline/eveonline.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package eveonline
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -160,3 +161,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
}
return newToken, err
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/facebook/facebook.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,8 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
func (p *Provider) RefreshTokenAvailable() bool {
return false
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
// TODO:
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/faux/faux.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package faux

import (
"encoding/json"
"errors"
"fmt"
"net/http"
"strings"
Expand Down Expand Up @@ -108,3 +109,7 @@ func (s *Session) Marshal() string {
func (s *Session) GetAuthURL() (string, error) {
return s.AuthURL, nil
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/fitbit/fitbit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package fitbit

import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -193,3 +194,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
func (p *Provider) RefreshTokenAvailable() bool {
return true
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/gitea/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package gitea
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -185,3 +186,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
}
return newToken, err
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
4 changes: 4 additions & 0 deletions providers/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
func (p *Provider) RefreshTokenAvailable() bool {
return false
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions providers/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package gitlab
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -186,3 +187,7 @@ func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
}
return newToken, err
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
return goth.User{}, errors.New("not implemented")
}
6 changes: 6 additions & 0 deletions providers/google/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package google

import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -209,3 +210,8 @@ func (p *Provider) SetAccessType(at string) {
}
p.authCodeOptions = append(p.authCodeOptions, oauth2.SetAuthURLParam("access_type", at))
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
//TODO: Implement this
return goth.User{}, errors.New("not implemented")
}
6 changes: 6 additions & 0 deletions providers/gplus/gplus.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package gplus
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -193,3 +194,8 @@ func (p *Provider) SetPrompt(prompt ...string) {
}
p.prompt = oauth2.SetAuthURLParam("prompt", strings.Join(prompt, " "))
}

func (p *Provider) FetchUserWithToken(token string) (goth.User, error) {
//TODO
return goth.User{}, errors.New("not implemented")
}
Loading

0 comments on commit 71ca33a

Please sign in to comment.