-
Notifications
You must be signed in to change notification settings - Fork 0
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
Return 403 instead of 404 for private published documents #135
Conversation
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.
Code looks good. A few small syntaxy things, but looks solid
src/api/opensearch.js
Outdated
statusCode: 404, | ||
body: JSON.stringify(responseBody), | ||
}; | ||
if (index != "shared_links") { |
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.
if (index != "shared_links") { | |
if (index !== "shared_links") { |
There's not a reason to do a strict check here, right?
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.
Oh probably not. Good catch.
src/api/opensearch.js
Outdated
}), | ||
}; | ||
} else if (!isVisible(body, opts)) { | ||
if (body?._source.published) { |
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.
If ya want, could re-write this block like:
response = body?._source.published
? { statusCode: 403 }
: {
statusCode: 404,
body: JSON.stringify({
_index: prefix(index),
_type: "_doc",
_id: id,
found: false,
})
};
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.
Done
@adamjarling - updated. Thanks. |
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.
Looking good
403
instead of404
for private published documents (this includesWorks
,FileSets
andCollections
responses.)