mirror of
https://github.com/grafana/grafana.git
synced 2024-12-28 01:41:24 -06:00
Auth: Fix for the github_oauth parse config error (#79063)
* Fix for reverting the github_oauth parse config behaviour * minimal changes
This commit is contained in:
parent
f51ad749ab
commit
d099292d99
@ -57,10 +57,7 @@ func NewGitHubProvider(settings map[string]any, cfg *setting.Cfg, features *feat
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
teamIds, err := mustInts(util.SplitString(info.Extra[teamIdsKey]))
|
teamIds := mustInts(util.SplitString(info.Extra[teamIdsKey]))
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
config := createOAuthConfig(info, cfg, GitHubProviderName)
|
config := createOAuthConfig(info, cfg, GitHubProviderName)
|
||||||
provider := &SocialGithub{
|
provider := &SocialGithub{
|
||||||
@ -329,14 +326,15 @@ func convertToGroupList(t []GithubTeam) []string {
|
|||||||
return groups
|
return groups
|
||||||
}
|
}
|
||||||
|
|
||||||
func mustInts(s []string) ([]int, error) {
|
func mustInts(s []string) []int {
|
||||||
result := make([]int, 0, len(s))
|
result := make([]int, 0, len(s))
|
||||||
for _, v := range s {
|
for _, v := range s {
|
||||||
num, err := strconv.Atoi(v)
|
num, err := strconv.Atoi(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
// TODO: add log here
|
||||||
|
return []int{}
|
||||||
}
|
}
|
||||||
result = append(result, num)
|
result = append(result, num)
|
||||||
}
|
}
|
||||||
return result, nil
|
return result
|
||||||
}
|
}
|
||||||
|
@ -307,6 +307,16 @@ func TestSocialGitHub_InitializeExtraFields(t *testing.T) {
|
|||||||
allowedOrganizations: []string{},
|
allowedOrganizations: []string{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "should not error when teamIds are not integers",
|
||||||
|
settings: map[string]any{
|
||||||
|
"team_ids": "abc1234,5678",
|
||||||
|
},
|
||||||
|
want: settingFields{
|
||||||
|
teamIds: []int{},
|
||||||
|
allowedOrganizations: []string{},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
|
Loading…
Reference in New Issue
Block a user