Skip to content
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

Secure preferences improvements #261

Merged
merged 30 commits into from
Jan 30, 2017
Merged

Secure preferences improvements #261

merged 30 commits into from
Jan 30, 2017

Conversation

Mognom
Copy link
Contributor

@Mognom Mognom commented Jan 16, 2017

Adds secure request support for operators

Adds secure preferences censorship (shows empty if no value provided and eight asterisks if it has any value.

Updates operator preferences on change instead of waiting to leave the wiring view.

MashupPlatform.prefs.get("secure-preference-name") can be used to get the display value of the preference (empty or 8 asterisks). This can be useful in order to check if the preference has any value.

@@ -604,7 +604,7 @@ def get_ajax_endpoints(self, view):
{'id': 'WORKSPACE_RESOURCE_COLLECTION', 'url': build_url_template('wirecloud.workspace_resource_collection', ['workspace_id'])},
{'id': 'WORKSPACE_VIEW', 'url': build_url_template('wirecloud.workspace_view', ['owner', 'name'])},

{'id': 'OPERATOR_PREFERENCES', 'url': build_url_template('wirecloud.workspace_operatorpref', ['workspace_id', 'operator_id'])},
{'id': 'OPERATOR_PREFERENCES', 'url': build_url_template('wirecloud.workspace_operator_preferences', ['workspace_id', 'operator_id'])},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

operator_preferences without the workspace_ prefix

@@ -18,6 +18,7 @@
# along with Wirecloud. If not, see <http://www.gnu.org/licenses/>.

import json
import jsonpatch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add the jsonpatch dependency into the src/setup.py and docs/installation_guide.md files.

workspace.wiringStatus = new_wiring_status
workspace.save()

return HttpResponse(status=200)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

200 error code needs a response body, please use a 204 error code instead.

operator_prefs = workspace.wiringStatus["operators"][operator_id]["preferences"]
for preference in new_values:
if not preference in operator_prefs:
return build_error_response(request, 400, _("Preference does not exist"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error has nothing to do with the request's content syntax, use a 422 error code instead.

@@ -33,17 +33,26 @@


WIRECLOUD_SECURE_DATA_HEADER = 'x-wirecloud-secure-data'
WIRECLOUD_COMPONENT_TYPE_HEADER = 'wirecloud-component-type'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing equivalent WIRECLOUD_COMPONENT_ID_HEADER and remove the use of the iwidget_id matching group for getting the component id (you should maintain it for detecting constants, maybe using another name for the matching group).

Examples:

  • Values from variables: action=basic_auth, user_ref=username, pass_ref=pref_secure
  • Username value from constant: action=basic_auth, user_ref=c/username, pass_ref=pref_secure

new_wiring_status = parse_json_request(request)
old_wiring_status = workspace.wiringStatus

def checkWiring(self, request, new_wiring_status, old_wiring_status, can_update_secure = False):
Copy link
Member

@aarranz aarranz Jan 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flake8 src/wirecloud/platform/wiring/views.py ;-)

Tip: pip install flake8

@aarranz
Copy link
Member

aarranz commented Jan 25, 2017

Missing Apiary documentation and the improvements in the error responses reviewed in slack.

@aarranz aarranz merged commit c8c019c into Wirecloud:develop Jan 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants