-
Notifications
You must be signed in to change notification settings - Fork 0
feat: disable jwt token #9
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,11 +29,14 @@ func init() { | |
| // Initialize JWT client if API config is provided | ||
| if config.APIConfig.Enabled && | ||
| config.APIConfig.PublicKeyPath != "" && config.APIConfig.BaseURL != "" { | ||
| err := gthulhuPlugin.InitJWTClient(config.APIConfig.PublicKeyPath, config.APIConfig.BaseURL) | ||
| err := gthulhuPlugin.InitJWTClient( | ||
| config.APIConfig.PublicKeyPath, | ||
| config.APIConfig.BaseURL, | ||
| config.APIConfig.AuthEnabled, | ||
| ) | ||
|
Comment on lines
30
to
+36
|
||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // Initialize metrics client | ||
| err = gthulhuPlugin.InitMetricsClient(config.APIConfig.BaseURL) | ||
| if err != nil { | ||
|
|
@@ -301,8 +304,12 @@ func (g *GthulhuPlugin) getTaskExecutionTime(pid int32) uint64 { | |
| } | ||
|
|
||
| // InitJWTClient initializes the JWT client for API authentication | ||
| func (g *GthulhuPlugin) InitJWTClient(publicKeyPath, apiBaseURL string) error { | ||
| g.jwtClient = NewJWTClient(publicKeyPath, apiBaseURL) | ||
| func (g *GthulhuPlugin) InitJWTClient( | ||
| publicKeyPath, | ||
| apiBaseURL string, | ||
| authEnabled bool, | ||
| ) error { | ||
| g.jwtClient = NewJWTClient(publicKeyPath, apiBaseURL, authEnabled) | ||
| return nil | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
GetAuthenticatedClientmethod does not respect theauthEnabledflag. WhileMakeAuthenticatedRequestwas updated to conditionally add authentication based onauthEnabled,GetAuthenticatedClientstill always callsensureValidTokenand creates anauthenticatedTransportthat adds the Authorization header. This means any code usingGetAuthenticatedClientwill still attempt JWT authentication even whenauthEnabledis false. The method should check theauthEnabledflag and either return a plain HTTP client or skip token validation when authentication is disabled.