Commit 8c04d06d authored by Robin Sonnabend's avatar Robin Sonnabend

Tried wiki api-auth with AuthRemoteUser.

Does not work.

ref #107
parent fd40e94c
......@@ -21,8 +21,10 @@
{% if protocol.source is not none %}
<a class="btn btn-primary" href="{{url_for("get_protocol_source", protocol_id=protocol.id)}}">Quelltext</a>
{% endif %}
{% if not protocol.public %}
{% if not protocol.public or has_admin_right %}
<a class="btn {% if protocol.is_done() %}btn-success{% else %}btn-default{% endif %}" href="{{url_for("update_protocol", protocol_id=protocol.id)}}">Editieren</a>
{% endif %}
{% if not protocol.public %}
{% if config.ETHERPAD_ACTIVE %}
<a class="btn btn-primary" href="{{url_for("etherpush_protocol", protocol_id=protocol.id)}}"{% if large_time_diff %} onclick="return confirm('Bist du dir sicher, dass du das Template bereits in das Etherpad kopieren willst? Die Sitzung ist erst in {{time_diff.days}} Tagen.');"{% endif %}>Etherpad</a>
{% endif %}
......
......@@ -4,6 +4,7 @@ import json
import config
HTTP_STATUS_OK = 200
HTTP_STATUS_AUTHENTICATE = 401
class WikiException(Exception):
pass
......@@ -88,11 +89,12 @@ class WikiClient:
kwargs["action"] = action
kwargs["format"] = "json"
params = _filter_params(kwargs)
req = None
if method == "get":
req = requests.get(self.endpoint, cookies=self.cookies, params=params)
elif method == "post":
req = requests.post(self.endpoint, cookies=self.cookies, data=data, params=params)
def _do_request():
if method == "get":
return requests.get(self.endpoint, cookies=self.cookies, params=params, auth=requests.auth.HTTPBasicAuth(self.user, self.password))
elif method == "post":
return requests.post(self.endpoint, cookies=self.cookies, data=data, params=params, auth=requests.auth.HTTPBasicAuth(self.user, self.password))
req = _do_request()
if req.status_code != HTTP_STATUS_OK:
raise WikiException("HTTP status code {} on action {}.".format(req.status_code, action))
self.cookies.update(req.cookies)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment