Skip to content

Update basic-auth.md - fix example#399

Open
AahilRafiq wants to merge 1 commit into
labstack:masterfrom
AahilRafiq:patch-1
Open

Update basic-auth.md - fix example#399
AahilRafiq wants to merge 1 commit into
labstack:masterfrom
AahilRafiq:patch-1

Conversation

@AahilRafiq
Copy link
Copy Markdown

  • 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
}))

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.

1 participant