Skip to content

Commit

Permalink
Merge pull request #1180 from Permify/refactor/oidc
Browse files Browse the repository at this point in the history
feat(authn): change OIDCSlogAdapter Debug logs to Info level
  • Loading branch information
tolgaOzen committed Mar 27, 2024
2 parents 4f6ed17 + e97d5c3 commit 7a86d88
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/authn/oidc/authn.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type Authn struct {
func NewOidcAuthn(ctx context.Context, conf config.Oidc) (*Authn, error) {
// Create a new HTTP client with retry capabilities. This client is used for making HTTP requests, particularly for fetching OIDC configuration.
client := retryablehttp.NewClient()
client.Logger = SlogAdapter{Logger: slog.Default()}
client.Logger = OIDCSlogAdapter{Logger: slog.Default()}

// Fetch the OIDC configuration from the issuer's well-known configuration endpoint.
oidcConf, err := fetchOIDCConfiguration(client.StandardClient(), strings.TrimSuffix(conf.Issuer, "/")+"/.well-known/openid-configuration")
Expand Down Expand Up @@ -296,27 +296,27 @@ func parseOIDCConfiguration(body []byte) (*Config, error) {
return &oidcConfig, nil
}

// SlogAdapter adapts the slog.Logger to be compatible with retryablehttp.LeveledLogger.
type SlogAdapter struct {
// OIDCSlogAdapter adapts the slog.Logger to be compatible with retryablehttp.LeveledLogger.
type OIDCSlogAdapter struct {
Logger *slog.Logger
}

// Error logs messages at error level.
func (a SlogAdapter) Error(msg string, keysAndValues ...interface{}) {
func (a OIDCSlogAdapter) Error(msg string, keysAndValues ...interface{}) {
a.Logger.Error(msg, keysAndValues...)
}

// Info logs messages at info level.
func (a SlogAdapter) Info(msg string, keysAndValues ...interface{}) {
func (a OIDCSlogAdapter) Info(msg string, keysAndValues ...interface{}) {
a.Logger.Info(msg, keysAndValues...)
}

// Debug logs messages at debug level.
func (a SlogAdapter) Debug(msg string, keysAndValues ...interface{}) {
a.Logger.Debug(msg, keysAndValues...)
func (a OIDCSlogAdapter) Debug(msg string, keysAndValues ...interface{}) {
a.Logger.Info(msg, keysAndValues...)
}

// Warn logs messages at warn level.
func (a SlogAdapter) Warn(msg string, keysAndValues ...interface{}) {
func (a OIDCSlogAdapter) Warn(msg string, keysAndValues ...interface{}) {
a.Logger.Warn(msg, keysAndValues...)
}

0 comments on commit 7a86d88

Please sign in to comment.