-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from qld-gov-au/develop
Develop to master
- Loading branch information
Showing
7 changed files
with
140 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,18 @@ | ||
from markupsafe import Markup | ||
from ckanext.csrf_filter.anti_csrf import get_response_token, TOKEN_FIELD_NAME | ||
|
||
try: | ||
from ckan.common import is_flask_request | ||
except ImportError: | ||
def is_flask_request(): | ||
return True | ||
|
||
|
||
def csrf_token_field(): | ||
if is_flask_request(): | ||
from flask import Response | ||
response = Response() | ||
else: | ||
from pylons import response | ||
token = get_response_token(response) | ||
return Markup('<input type="hidden" name="{}" value="{}"/>'.format(TOKEN_FIELD_NAME, token)) |
This file contains 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
15 changes: 15 additions & 0 deletions
15
ckanext/csrf_filter/templates/user/snippets/api_token_list.html
This file contains 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,15 @@ | ||
{% ckan_extends %} | ||
|
||
{% block token_cell_actions %} | ||
<td> | ||
{% set action = h.url_for("user.api_token_revoke", id=user['name'], jti=token['id']) %} | ||
<form action="{{ action }}" method="POST"> | ||
{{ h.csrf_input() }} | ||
<div class="btn-group"> | ||
<button type="submit" href="{{ action }}" class="btn btn-danger btn-sm" title="{{ _('Revoke') }}" data-module="confirm-action" data-module-with-data=true> | ||
<i class="fa fa-times"></i> | ||
</button> | ||
</div> | ||
</form> | ||
</td> | ||
{% endblock token_cell_actions %} |
This file contains 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