-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Add event ingester auth + sentry presets * Generate node name dynamically * Linting * Linting * linting * feat: Update golangci-lint version to v1.61 * build: Update golangci-lint-action to v6版本 * fix: Update authorization enabled status to false * feat: Add AuthConfig struct with validation method * feat: Add auth to coordinator * fix: Update auth enabled to false in xatu server config * feat: Add auth to coordinator
- Loading branch information
Showing
5 changed files
with
151 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package coordinator | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/metadata" | ||
"google.golang.org/grpc/status" | ||
) | ||
|
||
func (c *Client) validateAuth(ctx context.Context, md metadata.MD) error { | ||
if c.config.Auth.Enabled == nil || !*c.config.Auth.Enabled { | ||
return nil | ||
} | ||
|
||
authHeader := md.Get("Authorization") | ||
|
||
if len(authHeader) == 0 { | ||
return status.Errorf(codes.Unauthenticated, "missing authorization header") | ||
} | ||
|
||
token := authHeader[0] | ||
if token == "" { | ||
return status.Errorf(codes.Unauthenticated, "empty authorization header") | ||
} | ||
|
||
// Extract the secret from the token | ||
split := strings.Split(token, " ") | ||
if len(split) != 2 { | ||
return status.Errorf(codes.Unauthenticated, "invalid authorization header") | ||
} | ||
|
||
secret := split[1] | ||
|
||
if secret != c.config.Auth.Secret { | ||
return status.Errorf(codes.Unauthenticated, "invalid secret") | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters