MCPcopy Index your code
hub / github.com/coder/coder / ParseFormattedSecret

Function ParseFormattedSecret

coderd/oauth2provider/secrets.go:45–58  ·  view source on GitHub ↗

ParseFormattedSecret parses a formatted secret like "coder_ _<secret"

(formatted string)

Source from the content-addressed store, hash-verified

43
44// ParseFormattedSecret parses a formatted secret like "coder_<prefix>_<secret"
45func ParseFormattedSecret(formatted string) (AppSecret, error) {
46 parts := strings.Split(formatted, "_")
47 if len(parts) != 3 {
48 return AppSecret{}, xerrors.Errorf("incorrect number of parts: %d", len(parts))
49 }
50 if parts[0] != SecretIdentifier {
51 return AppSecret{}, xerrors.Errorf("incorrect scheme: %s", parts[0])
52 }
53 return AppSecret{
54 Formatted: formatted,
55 Prefix: parts[1],
56 Secret: parts[2],
57 }, nil
58}
59
60// GenerateSecret generates a secret to be used as a client secret, refresh
61// token, or authorization code.

Callers 4

revokeRefreshTokenInTxFunction · 0.85
authorizationCodeGrantFunction · 0.85
refreshTokenGrantFunction · 0.85

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected