-
Notifications
You must be signed in to change notification settings - Fork 332
[WPB-27953] Make scim error responses comply with RFC7644. #5439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fisx
wants to merge
4
commits into
develop
Choose a base branch
from
WPB-27953-make-scim-error-responses-comply-with-rfc7644
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
changelog.d/0-release-notes/WPB-27953-make-scim-error-responses-comply-with-rfc7644
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| Make SCIM error responses comply with RFC7644. Any code that processes SCIM error responses must be changed to follow the standard, instead of the previous Wire implementation. | ||
|
|
||
| Previous schema (incompatible with RFC): | ||
|
|
||
| ``` | ||
| { | ||
| "code": 400, | ||
| "label": "scim-error", | ||
| "message": "{\"detail\":\"[...]\",\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:Error\"],\"scimType\":\"invalidValue\",\"status\":\"400\"}" | ||
| } | ||
| ``` | ||
|
|
||
| New schema (RFC-compliant): | ||
|
|
||
| ``` | ||
| { | ||
| "schemas": ["urn:ietf:params:scim:api:messages:2.0:Error"], | ||
| "status": "400" | ||
| "scimType": "invalidValue", | ||
| "detail": "[...]", | ||
| } | ||
| ``` |
1 change: 1 addition & 0 deletions
1
changelog.d/1-api-changes/WPB-27953-make-scim-error-responses-comply-with-rfc7644
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Make scim error responses comply with RFC7644. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| {-# LANGUAGE OverloadedStrings #-} | ||
|
|
||
| -- This file is part of the Wire Server implementation. | ||
| -- | ||
| -- Copyright (C) 2025 Wire Swiss GmbH <opensource@wire.com> | ||
| -- | ||
| -- This program is free software: you can redistribute it and/or modify it under | ||
| -- the terms of the GNU Affero General Public License as published by the Free | ||
| -- Software Foundation, either version 3 of the License, or (at your option) any | ||
| -- later version. | ||
| -- | ||
| -- This program is distributed in the hope that it will be useful, but WITHOUT | ||
| -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| -- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
| -- details. | ||
| -- | ||
| -- You should have received a copy of the GNU Affero General Public License along | ||
| -- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| module Test.Spar.ErrorSpec where | ||
|
|
||
| import Data.Aeson (eitherDecode') | ||
| import Data.Aeson.QQ (aesonQQ) | ||
| import Imports | ||
| import qualified SAML2.WebSSO as SAML | ||
| import Servant (ServerError (..)) | ||
| import Spar.Error | ||
| import Test.Hspec | ||
| import qualified Web.Scim.Schema.Error as Scim | ||
|
|
||
| spec :: Spec | ||
| spec = describe "sparToServerError" $ do | ||
| -- RFC 7644 section 3.12 requires that the response body of a SCIM error *is* | ||
| -- the SCIM error object, not a wire-server 'Wai.Error' with the SCIM error | ||
| -- object nested (double-encoded) into its 'message' field. | ||
| it "renders a SCIM error as the bare RFC 7644 error object" $ do | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is great to show that the rendering works. But, it would also be good to prove that it is actually used. Either with dedicated integration or effect tests or by adding assertions to existing tests. I would lean to the latter, because that's quicker to do. |
||
| let scimErr = | ||
| Scim.badRequest | ||
| Scim.InvalidValue | ||
| (Just "Could not process externalId.") | ||
| serverErr = sparToServerError (SAML.CustomError (SparScimError scimErr)) | ||
| eitherDecode' (errBody serverErr) | ||
| `shouldBe` Right | ||
| [aesonQQ| | ||
| { | ||
| "detail": "Could not process externalId.", | ||
| "schemas": [ | ||
| "urn:ietf:params:scim:api:messages:2.0:Error" | ||
| ], | ||
| "scimType": "invalidValue", | ||
| "status": "400" | ||
| }|] | ||
| errHTTPCode serverErr `shouldBe` 400 | ||
| lookup "Content-Type" (errHeaders serverErr) | ||
| `shouldBe` Just "application/scim+json;charset=utf-8" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.