Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardcoded Secret Key in JWT Authentication Initialization #5

Closed
gtqbhksl opened this issue Aug 19, 2024 · 1 comment
Closed

Hardcoded Secret Key in JWT Authentication Initialization #5

gtqbhksl opened this issue Aug 19, 2024 · 1 comment

Comments

@gtqbhksl
Copy link

func init() {
service.RegisterAuth(New())

auth := jwt.New(&jwt.GfJWTMiddleware{
	Realm:           "test zone",
	Key:             []byte("secret key"),
	Timeout:         time.Minute * 5,
	MaxRefresh:      time.Minute * 5,
	IdentityKey:     "id",
	TokenLookup:     "header: Authorization, query: token, cookie: jwt",
	TokenHeadName:   "Bearer",
	TimeFunc:        time.Now,
	Authenticator:   Auth().Authenticator,
	Unauthorized:    Auth().Unauthorized,
	PayloadFunc:     Auth().PayloadFunc,
	IdentityHandler: Auth().IdentityHandler,
})
authService = auth

}

In file internal/logic/auth/auth. line 37, there is a hard coded Key (Key) value, namely the "secret Key". Hard-coded credentials (such as keys, passwords, API keys, etc.) are one of the common mistakes of security development. If an attacker has access to these hard-coded credentials, they may be able to exploit them
Data to access a system or service. Hard-coded credentials often lead to security risks because they make it easier for attackers to obtain sensitive information and potentially use it to perform malicious activities.

@demozx
Copy link
Owner

demozx commented Aug 19, 2024

@gtqbhksl Thanks, I fixed it

@demozx demozx closed this as completed Sep 2, 2024
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

No branches or pull requests

2 participants