Files
signoz/pkg/errors/code.go
Vibhu Pandey c122bc09b4 feat(tokenizer|sso): add tokenizer for session management and oidc sso support (#9183)
## 📄 Summary

- Instead of relying on JWT for session management, we are adding another token system: opaque. This gives the benefits of expiration and revocation.

- We are now ensuring that emails are regex checked throughout the backend.

- Support has been added for OIDC protocol
2025-10-16 18:00:38 +05:30

49 lines
1.0 KiB
Go

package errors
import (
"fmt"
"regexp"
)
var (
CodeInvalidInput Code = Code{"invalid_input"}
CodeInternal = Code{"internal"}
CodeUnsupported = Code{"unsupported"}
CodeNotFound = Code{"not_found"}
CodeMethodNotAllowed = Code{"method_not_allowed"}
CodeAlreadyExists = Code{"already_exists"}
CodeUnauthenticated = Code{"unauthenticated"}
CodeForbidden = Code{"forbidden"}
CodeCanceled = Code{"canceled"}
CodeTimeout = Code{"timeout"}
CodeUnknown = Code{"unknown"}
CodeLicenseUnavailable = Code{"license_unavailable"}
)
var (
codeRegex = regexp.MustCompile(`^[a-z_]+$`)
)
type Code struct{ s string }
func NewCode(s string) (Code, error) {
if !codeRegex.MatchString(s) {
return Code{}, fmt.Errorf("invalid code: %v", s)
}
return Code{s: s}, nil
}
func MustNewCode(s string) Code {
code, err := NewCode(s)
if err != nil {
panic(err)
}
return code
}
func (c Code) String() string {
return c.s
}