Skip to content

Commit

Permalink
chore(thirdparty): rename Linkedin provider config to LinkedIn
Browse files Browse the repository at this point in the history
also rename provider to LinkedIn instead of Linkedin

Related to: #1452
  • Loading branch information
Stefan Jacobi committed May 29, 2024
1 parent ec9bee8 commit 09eac11
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion backend/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ type ThirdPartyProviders struct {
Apple ThirdPartyProvider `yaml:"apple" json:"apple,omitempty" koanf:"apple"`
Discord ThirdPartyProvider `yaml:"discord" json:"discord,omitempty" koanf:"discord"`
Microsoft ThirdPartyProvider `yaml:"microsoft" json:"microsoft,omitempty" koanf:"microsoft"`
Linkedin ThirdPartyProvider `yaml:"linkedin" json:"linkedin" koanf:"linkedin"`
LinkedIn ThirdPartyProvider `yaml:"linkedin" json:"linkedin" koanf:"linkedin"`
}

func (p *ThirdPartyProviders) Validate() error {
Expand Down
2 changes: 1 addition & 1 deletion backend/thirdparty/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func GetProvider(config config.ThirdParty, name string) (OAuthProvider, error) {
case "microsoft":
return NewMicrosoftProvider(config.Providers.Microsoft, config.RedirectURL)
case "linkedin":
return NewLinkedinProvider(config.Providers.Linkedin, config.RedirectURL)
return NewLinkedInProvider(config.Providers.LinkedIn, config.RedirectURL)
default:
return nil, fmt.Errorf("provider '%s' is not supported", name)
}
Expand Down
20 changes: 10 additions & 10 deletions backend/thirdparty/provider_linkedin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

const (
LinkedinIssuer = "https://www.linkedin.com/oauth"
LinkedInIssuer = "https://www.linkedin.com/oauth"
)

var DefaultLinkedinScopes = []string{
Expand All @@ -33,24 +33,24 @@ type LinkedinUser struct {
Verified bool `json:"email_verified"`
}

type linkedinProvider struct {
type linkedInProvider struct {
oidc *oidc.Provider
*oauth2.Config
}

// NewLinkedinProvider creates a LinkedIn third party provider.
func NewLinkedinProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error) {
// NewLinkedInProvider creates a LinkedIn third party provider.
func NewLinkedInProvider(config config.ThirdPartyProvider, redirectURL string) (OAuthProvider, error) {
if !config.Enabled {
return nil, errors.New("linkedIn provider is disabled")
}

oidcProvider, err := oidc.NewProvider(context.Background(), LinkedinIssuer)
oidcProvider, err := oidc.NewProvider(context.Background(), LinkedInIssuer)
if err != nil {
return nil, err
}
endpoint := oidcProvider.Endpoint()

return &linkedinProvider{
return &linkedInProvider{
oidc: oidcProvider,
Config: &oauth2.Config{
ClientID: config.ClientID,
Expand All @@ -62,11 +62,11 @@ func NewLinkedinProvider(config config.ThirdPartyProvider, redirectURL string) (
}, nil
}

func (g linkedinProvider) GetOAuthToken(code string) (*oauth2.Token, error) {
func (g linkedInProvider) GetOAuthToken(code string) (*oauth2.Token, error) {
return g.Exchange(context.Background(), code)
}

func (g linkedinProvider) GetUserData(token *oauth2.Token) (*UserData, error) {
func (g linkedInProvider) GetUserData(token *oauth2.Token) (*UserData, error) {
var user LinkedinUser
if err := makeRequest(token, g.Config, g.oidc.UserInfoEndpoint(), &user); err != nil {
return nil, err
Expand All @@ -87,7 +87,7 @@ func (g linkedinProvider) GetUserData(token *oauth2.Token) (*UserData, error) {
}

data.Metadata = &Claims{
Issuer: LinkedinIssuer,
Issuer: LinkedInIssuer,
Subject: user.ID,
Name: user.Name,
FamilyName: user.FamilyName,
Expand All @@ -101,6 +101,6 @@ func (g linkedinProvider) GetUserData(token *oauth2.Token) (*UserData, error) {
return data, nil
}

func (g linkedinProvider) Name() string {
func (g linkedInProvider) Name() string {
return "linkedin"
}

0 comments on commit 09eac11

Please sign in to comment.