Skip to content

Commit

Permalink
Add logging for service usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Planlos5000 committed Dec 18, 2024
1 parent 7597554 commit 0cd5115
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions server/src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ func run(c *cli.Context) error {

var rt *realtime.Broker
if c.String("redis-address") != "" {
logger.Get().Infof("Connecting to redis at %v", c.String("redis-address"))
rt, err = realtime.NewRedis(realtime.RedisServer{
Addr: c.String("redis-address"),
Username: c.String("redis-username"),
Expand All @@ -276,6 +277,7 @@ func run(c *cli.Context) error {
logger.Get().Fatalf("failed to connect to redis message queue: %v", err)
}
} else {
logger.Get().Infof("Connecting to nats at %v", c.String("nats"))
rt, err = realtime.NewNats(c.String("nats"))
if err != nil {
logger.Get().Fatalf("failed to connect to nats message queue: %v", err)
Expand All @@ -296,27 +298,31 @@ func run(c *cli.Context) error {

providersMap := make(map[string]auth.AuthProviderConfiguration)
if c.String("auth-google-client-id") != "" && c.String("auth-google-client-secret") != "" && c.String("auth-callback-host") != "" {
logger.Get().Info("Using google authentication")
providersMap[(string)(types.AccountTypeGoogle)] = auth.AuthProviderConfiguration{
ClientId: c.String("auth-google-client-id"),
ClientSecret: c.String("auth-google-client-secret"),
RedirectUri: fmt.Sprintf("%s%s/login/google/callback", strings.TrimSuffix(c.String("auth-callback-host"), "/"), strings.TrimSuffix(basePath, "/")),
}
}
if c.String("auth-github-client-id") != "" && c.String("auth-github-client-secret") != "" && c.String("auth-callback-host") != "" {
logger.Get().Info("Using github authentication")
providersMap[(string)(types.AccountTypeGitHub)] = auth.AuthProviderConfiguration{
ClientId: c.String("auth-github-client-id"),
ClientSecret: c.String("auth-github-client-secret"),
RedirectUri: fmt.Sprintf("%s%s/login/github/callback", strings.TrimSuffix(c.String("auth-callback-host"), "/"), strings.TrimSuffix(basePath, "/")),
}
}
if c.String("auth-microsoft-client-id") != "" && c.String("auth-microsoft-client-secret") != "" && c.String("auth-callback-host") != "" {
logger.Get().Info("Using microsoft authentication")
providersMap[(string)(types.AccountTypeMicrosoft)] = auth.AuthProviderConfiguration{
ClientId: c.String("auth-microsoft-client-id"),
ClientSecret: c.String("auth-microsoft-client-secret"),
RedirectUri: fmt.Sprintf("%s%s/login/microsoft/callback", strings.TrimSuffix(c.String("auth-callback-host"), "/"), strings.TrimSuffix(basePath, "/")),
}
}
if c.String("auth-azure-ad-tenant-id") != "" && c.String("auth-azure-ad-client-id") != "" && c.String("auth-azure-ad-client-secret") != "" && c.String("auth-callback-host") != "" {
logger.Get().Info("Using azure authentication")
providersMap[(string)(types.AccountTypeAzureAd)] = auth.AuthProviderConfiguration{
TenantId: c.String("auth-azure-ad-tenant-id"),
ClientId: c.String("auth-azure-ad-client-id"),
Expand All @@ -325,13 +331,15 @@ func run(c *cli.Context) error {
}
}
if c.String("auth-apple-client-id") != "" && c.String("auth-apple-client-secret") != "" && c.String("auth-callback-host") != "" {
logger.Get().Info("Using apple authentication.")
providersMap[(string)(types.AccountTypeApple)] = auth.AuthProviderConfiguration{
ClientId: c.String("auth-apple-client-id"),
ClientSecret: c.String("auth-apple-client-secret"),
RedirectUri: fmt.Sprintf("%s%s/login/apple/callback", strings.TrimSuffix(c.String("auth-callback-host"), "/"), strings.TrimSuffix(basePath, "/")),
}
}
if c.String("auth-oidc-discovery-url") != "" && c.String("auth-oidc-client-id") != "" && c.String("auth-oidc-client-secret") != "" && c.String("auth-callback-host") != "" {
logger.Get().Info("Using oicd authentication.")
providersMap[(string)(types.AccountTypeOIDC)] = auth.AuthProviderConfiguration{
ClientId: c.String("auth-oidc-client-id"),
ClientSecret: c.String("auth-oidc-client-secret"),
Expand Down

0 comments on commit 0cd5115

Please sign in to comment.