mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Merge branch 'development-before-sso' of https://gitlab.com/mbugroup/lti-api into refactor-to-serve/with-middleware
This commit is contained in:
+27
-2
@@ -62,9 +62,34 @@ func setupRedis() *redis.Client {
|
||||
}
|
||||
|
||||
func setupSSO(ctx context.Context, rdb *redis.Client) {
|
||||
if err := sso.Init(ctx, config.SSOJWKSURL, config.SSOIssuer, config.SSOAllowedAudiences); err != nil {
|
||||
utils.Log.Fatalf("SSO initialization failed: %v", err)
|
||||
const (
|
||||
maxAttempts = 12
|
||||
retryDelay = 5 * time.Second
|
||||
)
|
||||
|
||||
var lastErr error
|
||||
for attempt := 1; attempt <= maxAttempts; attempt++ {
|
||||
if err := sso.Init(ctx, config.SSOJWKSURL, config.SSOIssuer, config.SSOAllowedAudiences); err != nil {
|
||||
lastErr = err
|
||||
utils.Log.WithError(err).Warnf("SSO initialization attempt %d/%d failed", attempt, maxAttempts)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
utils.Log.Fatalf("SSO initialization aborted: %v", ctx.Err())
|
||||
case <-time.After(retryDelay):
|
||||
}
|
||||
continue
|
||||
}
|
||||
lastErr = nil
|
||||
if attempt > 1 {
|
||||
utils.Log.Infof("SSO initialization succeeded after %d attempts", attempt)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if lastErr != nil {
|
||||
utils.Log.Fatalf("SSO initialization failed: %v", lastErr)
|
||||
}
|
||||
|
||||
if rdb != nil {
|
||||
session.SetRevocationStore(session.NewRevocationStore(rdb, config.SSOTokenBlacklistPrefix))
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user