Skip to content

Commit 1cb01e8

Browse files
fix(saml): do not fetch the claims and use orgID from domain (#8086)
* fix(saml): do not fetch the claims and use orgID from domain * fix(saml): do not fetch the claims and use orgID from domain
1 parent 595a500 commit 1cb01e8

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

ee/query-service/app/api/auth.go

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import (
99

1010
"go.uber.org/zap"
1111

12-
"github.com/SigNoz/signoz/pkg/http/render"
1312
"github.com/SigNoz/signoz/pkg/query-service/constants"
14-
"github.com/SigNoz/signoz/pkg/types/authtypes"
1513
"github.com/SigNoz/signoz/pkg/valuer"
1614
)
1715

@@ -25,29 +23,11 @@ func handleSsoError(w http.ResponseWriter, r *http.Request, redirectURL string)
2523

2624
// receiveSAML completes a SAML request and gets user logged in
2725
func (ah *APIHandler) receiveSAML(w http.ResponseWriter, r *http.Request) {
28-
claims, err := authtypes.ClaimsFromContext(r.Context())
29-
if err != nil {
30-
render.Error(w, err)
31-
return
32-
}
33-
orgID, err := valuer.NewUUID(claims.OrgID)
34-
if err != nil {
35-
render.Error(w, err)
36-
return
37-
}
38-
3926
// this is the source url that initiated the login request
4027
redirectUri := constants.GetDefaultSiteURL()
4128
ctx := context.Background()
4229

43-
_, err = ah.Signoz.Licensing.GetActive(ctx, orgID)
44-
if err != nil {
45-
zap.L().Error("[receiveSAML] sso requested but feature unavailable in org domain")
46-
http.Redirect(w, r, fmt.Sprintf("%s?ssoerror=%s", redirectUri, "feature unavailable, please upgrade your billing plan to access this feature"), http.StatusMovedPermanently)
47-
return
48-
}
49-
50-
err = r.ParseForm()
30+
err := r.ParseForm()
5131
if err != nil {
5232
zap.L().Error("[receiveSAML] failed to process response - invalid response from IDP", zap.Error(err), zap.Any("request", r))
5333
handleSsoError(w, r, redirectUri)
@@ -76,6 +56,19 @@ func (ah *APIHandler) receiveSAML(w http.ResponseWriter, r *http.Request) {
7656
return
7757
}
7858

59+
orgID, err := valuer.NewUUID(domain.OrgID)
60+
if err != nil {
61+
handleSsoError(w, r, redirectUri)
62+
return
63+
}
64+
65+
_, err = ah.Signoz.Licensing.GetActive(ctx, orgID)
66+
if err != nil {
67+
zap.L().Error("[receiveSAML] sso requested but feature unavailable in org domain")
68+
http.Redirect(w, r, fmt.Sprintf("%s?ssoerror=%s", redirectUri, "feature unavailable, please upgrade your billing plan to access this feature"), http.StatusMovedPermanently)
69+
return
70+
}
71+
7972
sp, err := domain.PrepareSamlRequest(parsedState)
8073
if err != nil {
8174
zap.L().Error("[receiveSAML] failed to prepare saml request for domain", zap.String("domain", domain.String()), zap.Error(err))

0 commit comments

Comments
 (0)