mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-06-04 11:25:52 +08:00

* [feat] initial version for google oauth * chore: arranged the sso packages and added prepare request for google auth * feat: added google auth config page and backend to handle the request * chore: code cleanup for domain SSO parsing * Update constants.go * chore: moved redirect sso error * chore: lint issue fixed with domain * chore: added tooltip for enforce sso and few changes to auth domain * chore: moved question mark in enforce sso * fix: resolved pr review comments * chore: fixed type check for saml config * fix: fixed saml config form * chore: added util for transformed form values to samlconfig Co-authored-by: mindhash <mindhash@mindhashs-MacBook-Pro.local> Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com> Co-authored-by: Ankit Nayan <ankit@signoz.io>
109 lines
2.8 KiB
Go
109 lines
2.8 KiB
Go
package model
|
|
|
|
import (
|
|
"fmt"
|
|
basemodel "go.signoz.io/signoz/pkg/query-service/model"
|
|
)
|
|
|
|
type ApiError struct {
|
|
Typ basemodel.ErrorType
|
|
Err error
|
|
}
|
|
|
|
func (a *ApiError) Type() basemodel.ErrorType {
|
|
return a.Typ
|
|
}
|
|
|
|
func (a *ApiError) ToError() error {
|
|
if a != nil {
|
|
return a.Err
|
|
}
|
|
return a.Err
|
|
}
|
|
|
|
func (a *ApiError) Error() string {
|
|
return a.Err.Error()
|
|
}
|
|
|
|
func (a *ApiError) IsNil() bool {
|
|
return a == nil || a.Err == nil
|
|
}
|
|
|
|
// NewApiError returns a ApiError object of given type
|
|
func NewApiError(typ basemodel.ErrorType, err error) *ApiError {
|
|
return &ApiError{
|
|
Typ: typ,
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
// BadRequest returns a ApiError object of bad request
|
|
func BadRequest(err error) *ApiError {
|
|
return &ApiError{
|
|
Typ: basemodel.ErrorBadData,
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
// BadRequestStr returns a ApiError object of bad request for string input
|
|
func BadRequestStr(s string) *ApiError {
|
|
return &ApiError{
|
|
Typ: basemodel.ErrorBadData,
|
|
Err: fmt.Errorf(s),
|
|
}
|
|
}
|
|
|
|
// InternalError returns a ApiError object of internal type
|
|
func InternalError(err error) *ApiError {
|
|
return &ApiError{
|
|
Typ: basemodel.ErrorInternal,
|
|
Err: err,
|
|
}
|
|
}
|
|
|
|
|
|
// InternalErrorStr returns a ApiError object of internal type for string input
|
|
func InternalErrorStr(s string) *ApiError {
|
|
return &ApiError{
|
|
Typ: basemodel.ErrorInternal,
|
|
Err: fmt.Errorf(s),
|
|
}
|
|
}
|
|
var (
|
|
ErrorNone basemodel.ErrorType = ""
|
|
ErrorTimeout basemodel.ErrorType = "timeout"
|
|
ErrorCanceled basemodel.ErrorType = "canceled"
|
|
ErrorExec basemodel.ErrorType = "execution"
|
|
ErrorBadData basemodel.ErrorType = "bad_data"
|
|
ErrorInternal basemodel.ErrorType = "internal"
|
|
ErrorUnavailable basemodel.ErrorType = "unavailable"
|
|
ErrorNotFound basemodel.ErrorType = "not_found"
|
|
ErrorNotImplemented basemodel.ErrorType = "not_implemented"
|
|
ErrorUnauthorized basemodel.ErrorType = "unauthorized"
|
|
ErrorForbidden basemodel.ErrorType = "forbidden"
|
|
ErrorConflict basemodel.ErrorType = "conflict"
|
|
ErrorStreamingNotSupported basemodel.ErrorType = "streaming is not supported"
|
|
)
|
|
|
|
func init() {
|
|
ErrorNone = basemodel.ErrorNone
|
|
ErrorTimeout = basemodel.ErrorTimeout
|
|
ErrorCanceled = basemodel.ErrorCanceled
|
|
ErrorExec = basemodel.ErrorExec
|
|
ErrorBadData = basemodel.ErrorBadData
|
|
ErrorInternal = basemodel.ErrorInternal
|
|
ErrorUnavailable = basemodel.ErrorUnavailable
|
|
ErrorNotFound = basemodel.ErrorNotFound
|
|
ErrorNotImplemented = basemodel.ErrorNotImplemented
|
|
ErrorUnauthorized = basemodel.ErrorUnauthorized
|
|
ErrorForbidden = basemodel.ErrorForbidden
|
|
ErrorConflict = basemodel.ErrorConflict
|
|
ErrorStreamingNotSupported = basemodel.ErrorStreamingNotSupported
|
|
}
|
|
|
|
type ErrUnsupportedAuth struct{}
|
|
|
|
func (errUnsupportedAuth ErrUnsupportedAuth) Error() string {
|
|
return "this authentication method not supported"
|
|
}
|