mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-28 04:35:40 +00:00
fix: fix oauth group provider check
This commit is contained in:
@@ -147,10 +147,6 @@ func (app *BootstrapApp) Setup() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Configured providers
|
// Configured providers
|
||||||
babysit := map[string]string{
|
|
||||||
"google": "Google",
|
|
||||||
"github": "GitHub",
|
|
||||||
}
|
|
||||||
configuredProviders := make([]controller.Provider, 0)
|
configuredProviders := make([]controller.Provider, 0)
|
||||||
|
|
||||||
for id, provider := range oauthProviders {
|
for id, provider := range oauthProviders {
|
||||||
@@ -159,7 +155,7 @@ func (app *BootstrapApp) Setup() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if provider.Name == "" {
|
if provider.Name == "" {
|
||||||
if name, ok := babysit[id]; ok {
|
if name, ok := config.OverrideProviders[id]; ok {
|
||||||
provider.Name = name
|
provider.Name = name
|
||||||
} else {
|
} else {
|
||||||
provider.Name = utils.Capitalize(id)
|
provider.Name = utils.Capitalize(id)
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ type OAuthServiceConfig struct {
|
|||||||
Name string `key:"name"`
|
Name string `key:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var OverrideProviders = map[string]string{
|
||||||
|
"google": "Google",
|
||||||
|
"github": "GitHub",
|
||||||
|
}
|
||||||
|
|
||||||
// User/session related stuff
|
// User/session related stuff
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
|
|||||||
@@ -309,12 +309,14 @@ func (auth *AuthService) IsInOAuthGroup(c *gin.Context, context config.UserConte
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if context.Provider != "generic" {
|
for id := range config.OverrideProviders {
|
||||||
log.Debug().Msg("Not using generic provider, skipping group check")
|
if context.Provider == id {
|
||||||
return true
|
log.Info().Str("provider", id).Msg("OAuth groups not supported for this provider")
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, userGroup := range strings.Split(context.OAuthGroups, ",") {
|
for userGroup := range strings.SplitSeq(context.OAuthGroups, ",") {
|
||||||
if utils.CheckFilter(requiredGroups, strings.TrimSpace(userGroup)) {
|
if utils.CheckFilter(requiredGroups, strings.TrimSpace(userGroup)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,14 +183,13 @@ func GetOAuthProvidersConfig(env []string, args []string, appUrl string) (map[st
|
|||||||
providers[name] = provider
|
providers[name] = provider
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have google/github providers and no redirect URL babysit them
|
// If we have google/github providers and no redirect URL then set a default
|
||||||
babysitProviders := []string{"google", "github"}
|
|
||||||
|
|
||||||
for _, name := range babysitProviders {
|
for id := range config.OverrideProviders {
|
||||||
if provider, exists := providers[name]; exists {
|
if provider, exists := providers[id]; exists {
|
||||||
if provider.RedirectURL == "" {
|
if provider.RedirectURL == "" {
|
||||||
provider.RedirectURL = appUrl + "/api/oauth/callback/" + name
|
provider.RedirectURL = appUrl + "/api/oauth/callback/" + id
|
||||||
providers[name] = provider
|
providers[id] = provider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user