Oauth: Remove unused function for oauth implementations (#58887)

* Oauth: remove unused function

* Oauth: remove unused Oauth types
This commit is contained in:
Karl Persson
2022-11-17 15:03:15 +01:00
committed by GitHub
parent 7e9d94cfda
commit 6e3cb2e3ed
9 changed files with 0 additions and 53 deletions
-5
View File
@@ -8,7 +8,6 @@ import (
"net/http"
"strings"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/org"
"golang.org/x/oauth2"
@@ -46,10 +45,6 @@ type azureAccessClaims struct {
TenantID string `json:"tid"`
}
func (s *SocialAzureAD) Type() int {
return int(models.AZUREAD)
}
func (s *SocialAzureAD) UserInfo(client *http.Client, token *oauth2.Token) (*BasicUserInfo, error) {
idToken := token.Extra("id_token")
if idToken == nil {
-5
View File
@@ -13,7 +13,6 @@ import (
"regexp"
"strconv"
"github.com/grafana/grafana/pkg/models"
"golang.org/x/oauth2"
)
@@ -32,10 +31,6 @@ type SocialGenericOAuth struct {
teamIds []string
}
func (s *SocialGenericOAuth) Type() int {
return int(models.GENERIC)
}
func (s *SocialGenericOAuth) IsTeamMember(client *http.Client) bool {
if len(s.teamIds) == 0 {
return true
-6
View File
@@ -7,8 +7,6 @@ import (
"net/http"
"regexp"
"github.com/grafana/grafana/pkg/models"
"golang.org/x/oauth2"
)
@@ -33,10 +31,6 @@ var (
ErrMissingOrganizationMembership = Error{"user not a member of one of the required organizations"}
)
func (s *SocialGithub) Type() int {
return int(models.GITHUB)
}
func (s *SocialGithub) IsTeamMember(client *http.Client) bool {
if len(s.teamIds) == 0 {
return true
-6
View File
@@ -6,8 +6,6 @@ import (
"net/http"
"regexp"
"github.com/grafana/grafana/pkg/models"
"golang.org/x/oauth2"
)
@@ -17,10 +15,6 @@ type SocialGitlab struct {
apiUrl string
}
func (s *SocialGitlab) Type() int {
return int(models.GITLAB)
}
func (s *SocialGitlab) IsGroupMember(groups []string) bool {
if len(s.allowedGroups) == 0 {
return true
-6
View File
@@ -5,8 +5,6 @@ import (
"fmt"
"net/http"
"github.com/grafana/grafana/pkg/models"
"golang.org/x/oauth2"
)
@@ -16,10 +14,6 @@ type SocialGoogle struct {
apiUrl string
}
func (s *SocialGoogle) Type() int {
return int(models.GOOGLE)
}
func (s *SocialGoogle) UserInfo(client *http.Client, token *oauth2.Token) (*BasicUserInfo, error) {
var data struct {
Id string `json:"id"`
-5
View File
@@ -5,7 +5,6 @@ import (
"fmt"
"net/http"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/org"
"golang.org/x/oauth2"
@@ -21,10 +20,6 @@ type OrgRecord struct {
Login string `json:"login"`
}
func (s *SocialGrafanaCom) Type() int {
return int(models.GRAFANA_COM)
}
func (s *SocialGrafanaCom) IsEmailAllowed(email string) bool {
return true
}
-5
View File
@@ -6,7 +6,6 @@ import (
"fmt"
"net/http"
"github.com/grafana/grafana/pkg/models"
"golang.org/x/oauth2"
"gopkg.in/square/go-jose.v2/jwt"
)
@@ -44,10 +43,6 @@ func (claims *OktaClaims) extractEmail() string {
return claims.Email
}
func (s *SocialOkta) Type() int {
return int(models.OKTA)
}
func (s *SocialOkta) UserInfo(client *http.Client, token *oauth2.Token) (*BasicUserInfo, error) {
idToken := token.Extra("id_token")
if idToken == nil {
-1
View File
@@ -240,7 +240,6 @@ func (b *BasicUserInfo) String() string {
}
type SocialConnector interface {
Type() int
UserInfo(client *http.Client, token *oauth2.Token) (*BasicUserInfo, error)
IsEmailAllowed(email string) bool
IsSignupAllowed() bool
-14
View File
@@ -1,14 +0,0 @@
package models
type OAuthType int
const (
GITHUB OAuthType = iota + 1
GOOGLE
TWITTER
GENERIC
GRAFANA_COM
GITLAB
AZUREAD
OKTA
)