mirror of
https://github.com/steveiliop56/tinyauth.git
synced 2025-10-29 21:25:43 +00:00
Compare commits
2 Commits
v3.0.0-alp
...
v3.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9ab9a6406 | ||
|
|
6f35923735 |
@@ -62,7 +62,9 @@ var rootCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create oauth whitelist
|
// Create oauth whitelist
|
||||||
oauthWhitelist := strings.Split(config.OAuthWhitelist, ",")
|
oauthWhitelist := utils.Filter(strings.Split(config.OAuthWhitelist, ","), func(val string) bool {
|
||||||
|
return val != ""
|
||||||
|
})
|
||||||
log.Debug().Msg("Parsed OAuth whitelist")
|
log.Debug().Msg("Parsed OAuth whitelist")
|
||||||
|
|
||||||
// Create OAuth config
|
// Create OAuth config
|
||||||
|
|||||||
@@ -207,3 +207,13 @@ func GetTinyauthLabels(labels map[string]string) types.TinyauthLabels {
|
|||||||
func OAuthConfigured(config types.Config) bool {
|
func OAuthConfigured(config types.Config) bool {
|
||||||
return (config.GithubClientId != "" && config.GithubClientSecret != "") || (config.GoogleClientId != "" && config.GoogleClientSecret != "") || (config.GenericClientId != "" && config.GenericClientSecret != "") || (config.TailscaleClientId != "" && config.TailscaleClientSecret != "")
|
return (config.GithubClientId != "" && config.GithubClientSecret != "") || (config.GoogleClientId != "" && config.GoogleClientSecret != "") || (config.GenericClientId != "" && config.GenericClientSecret != "") || (config.TailscaleClientId != "" && config.TailscaleClientSecret != "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filter helper function
|
||||||
|
func Filter[T any](slice []T, test func(T) bool) (res []T) {
|
||||||
|
for _, value := range slice {
|
||||||
|
if test(value) {
|
||||||
|
res = append(res, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|||||||
@@ -313,3 +313,22 @@ func TestGetTinyauthLabels(t *testing.T) {
|
|||||||
t.Fatalf("Expected %v, got %v", expected, result)
|
t.Fatalf("Expected %v, got %v", expected, result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test the filter function
|
||||||
|
func TestFilter(t *testing.T) {
|
||||||
|
t.Log("Testing filter helper")
|
||||||
|
|
||||||
|
// Create variables
|
||||||
|
data := []string{"", "val1", "", "val2", "", "val3", ""}
|
||||||
|
expected := []string{"val1", "val2", "val3"}
|
||||||
|
|
||||||
|
// Test the filter function
|
||||||
|
result := utils.Filter(data, func(val string) bool {
|
||||||
|
return val != ""
|
||||||
|
})
|
||||||
|
|
||||||
|
// Check if the result is equal to the expected
|
||||||
|
if !reflect.DeepEqual(expected, result) {
|
||||||
|
t.Fatalf("Expected %v, got %v", expected, result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,7 +31,11 @@ export const ContinuePage = () => {
|
|||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!URL.canParse(redirectUri)) {
|
let uri;
|
||||||
|
|
||||||
|
try {
|
||||||
|
uri = new URL(redirectUri);
|
||||||
|
} catch {
|
||||||
return (
|
return (
|
||||||
<ContinuePageLayout>
|
<ContinuePageLayout>
|
||||||
<Text size="xl" fw={700}>
|
<Text size="xl" fw={700}>
|
||||||
@@ -45,8 +49,6 @@ export const ContinuePage = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uri = new URL(redirectUri);
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
window.location.protocol === "https:" &&
|
window.location.protocol === "https:" &&
|
||||||
uri.protocol === "http:"
|
uri.protocol === "http:"
|
||||||
|
|||||||
Reference in New Issue
Block a user