generated from ydataai/go-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
727 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/ydataai/authentication-service/internal/clients" | ||
"github.com/ydataai/authentication-service/internal/controllers" | ||
"github.com/ydataai/authentication-service/internal/services" | ||
"github.com/ydataai/authentication-service/internal/storages" | ||
"github.com/ydataai/go-core/pkg/common/config" | ||
"github.com/ydataai/go-core/pkg/common/logging" | ||
"github.com/ydataai/go-core/pkg/common/server" | ||
) | ||
|
||
var ( | ||
errChan = make(chan error) | ||
) | ||
|
||
func main() { | ||
loggerConfiguration := logging.LoggerConfiguration{} | ||
serverConfiguration := server.HTTPServerConfiguration{} | ||
oidcConfiguration := clients.OIDCConfiguration{} | ||
restConfiguration := controllers.RESTControllerConfiguration{} | ||
sessionStorageConfiguration := storages.SessionStorageConfiguration{} | ||
|
||
if err := config.InitConfigurationVariables([]config.ConfigurationVariables{ | ||
&loggerConfiguration, | ||
&serverConfiguration, | ||
&oidcConfiguration, | ||
&restConfiguration, | ||
&sessionStorageConfiguration, | ||
}); err != nil { | ||
fmt.Println(fmt.Errorf("[✖️] Could not set configuration variables. Err: %v", err)) | ||
os.Exit(1) | ||
} | ||
|
||
logger := logging.NewLogger(loggerConfiguration) | ||
|
||
logger.Info("Starting: Authentication Service") | ||
|
||
oidcClient := clients.NewOIDCClient(logger, oidcConfiguration) | ||
|
||
// Start OIDC Provider setup. | ||
oidcClient.StartSetup() | ||
|
||
// Initializes a storage to save temporary sessions configured with TTL. | ||
sessionStorage := storages.NewSessionStorage(sessionStorageConfiguration) | ||
|
||
oidcService := services.NewOIDCService(logger, oidcClient, sessionStorage) | ||
|
||
restController := controllers.NewRESTController(logger, restConfiguration, oidcService) | ||
|
||
httpServer := server.NewServer(logger, serverConfiguration) | ||
restController.Boot(httpServer) | ||
httpServer.Run(context.Background()) | ||
|
||
// HealthCheck | ||
httpServer.AddHealthz() | ||
httpServer.AddReadyz(func() bool { return true }) | ||
|
||
for err := range errChan { | ||
logger.Error(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.