Skip to content

Update basic-auth.md - fix example#399

Merged
aldas merged 1 commit into
labstack:masterfrom
AahilRafiq:patch-1
Jun 8, 2026
Merged

Update basic-auth.md - fix example#399
aldas merged 1 commit into
labstack:masterfrom
AahilRafiq:patch-1

Conversation

@AahilRafiq

Copy link
Copy Markdown
Contributor
  • reflect the updated function signature of Basic auth validator

Before

e.Use(middleware.BasicAuth(func(username, password string, c *echo.Context) (bool, error) {
	// Be careful to use constant time comparison to prevent timing attacks
	if subtle.ConstantTimeCompare([]byte(username), []byte("joe")) == 1 &&
		subtle.ConstantTimeCompare([]byte(password), []byte("secret")) == 1 {
		return true, nil
	}
	return false, nil
}))

After

e.Use(middleware.BasicAuth(func(c *echo.Context, username, password string) (bool, error) {
	// Be careful to use constant time comparison to prevent timing attacks
	if subtle.ConstantTimeCompare([]byte(username), []byte("joe")) == 1 &&
		subtle.ConstantTimeCompare([]byte(password), []byte("secret")) == 1 {
		return true, nil
	}
	return false, nil
}))

@aldas aldas merged commit e41374b into labstack:master Jun 8, 2026
1 check passed
@aldas

aldas commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants