• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gatewayd-io / gatewayd-plugin-auth / 22079911920

16 Feb 2026 10:57PM UTC coverage: 51.923%. First build
22079911920

push

github

mostafa
Add CI workflows, linter config, and fix all lint issues

- Add GitHub Actions workflows for test, release, and signed commits
- Add .golangci.yaml with enable-all linter configuration
- Add build-release and build-platform targets to Makefile
- Fix all 38 golangci-lint issues across the codebase:
  - Extract constants for action strings, magic numbers, and static errors
  - Rename PluginConfigValues to ConfigValues to avoid stutter
  - Pass context through all handler methods (contextcheck)
  - Use proto getters instead of direct field access (protogetter)
  - Fix import ordering (gci), comment formatting (godot)
  - Use non-deprecated GetStoredCredentialsWithError API
  - Remove local SDK replace directive from go.mod

40 of 77 new or added lines in 5 files covered. (51.95%)

459 of 884 relevant lines covered (51.92%)

5.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

56.52
/plugin/protocol.go
1
package plugin
2

3
import (
4
        "crypto/rand"
5
        "encoding/base64"
6
        "errors"
7
        "fmt"
8

9
        "github.com/gatewayd-io/gatewayd-plugin-sdk/databases/postgres"
10
        "github.com/spf13/cast"
11
)
12

13
var (
14
        // ErrNoParameters is returned when a startup message has no parameters.
15
        ErrNoParameters = errors.New("no parameters in startup message")
16
        // ErrNoUser is returned when a startup message has no user parameter.
17
        ErrNoUser = errors.New("no user in startup message")
18
)
19

20
// GenerateSalt generates a random salt of SaltSize bytes.
21
func GenerateSalt(_ int) ([SaltSize]byte, error) {
3✔
22
        var salt [SaltSize]byte
3✔
23
        if _, err := rand.Read(salt[:]); err != nil {
3✔
24
                return salt, fmt.Errorf("generating salt: %w", err)
×
25
        }
×
26
        return salt, nil
3✔
27
}
28

29
// BuildAuthFailResponse builds a Terminate+ErrorResponse for authentication failure.
30
func BuildAuthFailResponse(detail string) ([]byte, error) {
8✔
31
        return postgres.BuildTerminateWithError(
8✔
32
                ErrorMsgAuthFail,
8✔
33
                ErrorSeverity,
8✔
34
                ErrorCodeAuthFail,
8✔
35
                detail,
8✔
36
        )
8✔
37
}
8✔
38

39
// BuildAccessDeniedResponse builds a Terminate+ErrorResponse for authorization denial.
40
func BuildAccessDeniedResponse(detail string) ([]byte, error) {
×
41
        return postgres.BuildTerminateWithError(
×
42
                ErrorMsgDenied,
×
43
                ErrorSeverity,
×
44
                ErrorCodeDenied,
×
45
                detail,
×
46
        )
×
47
}
×
48

49
// DecodeBase64Field decodes a base64-encoded string field from the request struct.
50
func DecodeBase64Field(encoded string) ([]byte, error) {
11✔
51
        return base64.StdEncoding.DecodeString(encoded)
11✔
52
}
11✔
53

54
// ParseStartupParams extracts user and database from a decoded startup message.
55
func ParseStartupParams(startupDecoded []byte) (string, string, error) {
7✔
56
        startupMap := cast.ToStringMap(string(startupDecoded))
7✔
57
        parameters := cast.ToStringMapString(startupMap["Parameters"])
7✔
58
        if parameters == nil {
7✔
NEW
59
                return "", "", ErrNoParameters
×
60
        }
×
61

62
        user := parameters[ParamUser]
7✔
63
        database := parameters[ParamDatabase]
7✔
64
        if user == "" {
7✔
NEW
65
                return "", "", ErrNoUser
×
66
        }
×
67

68
        return user, database, nil
7✔
69
}
70

71
// ParsePasswordMessage extracts the password from a decoded password message.
72
func ParsePasswordMessage(passwordDecoded []byte) map[string]string {
4✔
73
        return cast.ToStringMapString(string(passwordDecoded))
4✔
74
}
4✔
75

76
// GetClientRemote extracts the client remote address from the request fields.
77
func GetClientRemote(fields map[string]interface{}) string {
×
78
        if client, ok := fields["client"]; ok {
×
79
                clientMap := cast.ToStringMap(client)
×
80
                return cast.ToString(clientMap["remote"])
×
81
        }
×
82
        return ""
×
83
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc