mirror of
https://github.com/OpenBankProject/API-Manager.git
synced 2026-02-06 15:26:46 +00:00
Add IP, response body columns to Metrics, start autocomplete feature.
This commit is contained in:
parent
385faab72e
commit
a05fc3b770
@ -354,8 +354,8 @@ if not OAUTH_CONSUMER_SECRET:
|
||||
|
||||
CSP_IMG_SRC = ("'self' data:", 'https://static.openbankproject.com')
|
||||
CSP_STYLE_SRC = ("'self' 'sha256-z2a+NIknPDE7NIEqE1lfrnG39eWOhJXWsXHYGGNb5oU=' 'sha256-Dn0vMZLidJplZ4cSlBMg/F5aa7Vol9dBMHzBF4fGEtk=' 'sha256-sA0hymKbXmMTpnYi15KmDw4u6uRdLXqHyoYIaORFtjU=' 'sha256-jUuiwf3ITuJc/jfynxWHLwTZifHIlhddD8NPmmVBztk=' 'sha256-RqzjtXRBqP4i+ruV3IRuHFq6eGIACITqGbu05VSVXsI='", 'https://cdnjs.cloudflare.com', )
|
||||
CSP_SCRIPT_SRC = ("'self' 'unsafe-eval' 'sha256-4Hr8ttnXaUA4A6o0hGi3NUGNP2Is3Ep0W+rvm+W7BAk=' 'sha256-GgQWQ4Ejk4g9XpAZJ4YxIgZDgp7CdQCmqjMOMh9hD2g=' 'sha256-05NIAwVBHkAzKcXTfkYqTnBPtkpX+AmQvM/raql3qo0='", 'http://code.jquery.com', 'https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/', 'https://cdnjs.cloudflare.com')
|
||||
CSP_SCRIPT_SRC = ("'self' 'unsafe-eval' 'sha256-CAykt4V7LQN6lEkjV8hZQx0GV6LTZZGUvQDqamuUq2Q=' 'sha256-4Hr8ttnXaUA4A6o0hGi3NUGNP2Is3Ep0W+rvm+W7BAk=' 'sha256-GgQWQ4Ejk4g9XpAZJ4YxIgZDgp7CdQCmqjMOMh9hD2g=' 'sha256-05NIAwVBHkAzKcXTfkYqTnBPtkpX+AmQvM/raql3qo0='", 'http://code.jquery.com', 'https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/', 'https://cdnjs.cloudflare.com')
|
||||
CSP_FONT_SRC = ("'self'", 'http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/fonts/')
|
||||
CSP_FRAME_ANCESTORS = ("'self'")
|
||||
CSP_FORM_ACTION = ("'self'")
|
||||
CSP_CONNECT_SRC = (API_HOST)
|
||||
CSP_CONNECT_SRC = ("'self'", API_HOST)
|
||||
|
||||
1314
apimanager/base/static/css/jquery-ui.css
vendored
Normal file
1314
apimanager/base/static/css/jquery-ui.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
18706
apimanager/base/static/js/jquery-ui.js
vendored
Normal file
18706
apimanager/base/static/js/jquery-ui.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -14,6 +14,7 @@
|
||||
<link href="{% static 'css/base.css' %}" rel="stylesheet">
|
||||
<link href="{% static 'css/jsoneditor.min.css' %}" rel="stylesheet">
|
||||
<link href="{% static 'css/obpjsoneditor.css' %}" rel="stylesheet">
|
||||
<link href="{% static 'css/jquery-ui.css' %}" rel="stylesheet">
|
||||
{% block extracss %}{% endblock extracss %}
|
||||
</head>
|
||||
|
||||
@ -148,6 +149,7 @@
|
||||
<script type="text/javascript" src="{% static 'js/jquery.min.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/bootstrap.min.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/jquery.tablesorter.min.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/jquery-ui.js' %}"></script>
|
||||
<script src="{% static 'js/base.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/jsoneditor.min.js' %}"></script>
|
||||
<script type="module" defer src="{% static 'js/inactivity.js' %}"></script>
|
||||
|
||||
@ -4,7 +4,7 @@ Views for base app
|
||||
"""
|
||||
from django.contrib import messages
|
||||
from django.conf import settings
|
||||
from django.views.generic import TemplateView
|
||||
from django.views.generic import TemplateView, View
|
||||
from django.shortcuts import render
|
||||
from obp.forms import DirectLoginForm, GatewayLoginForm
|
||||
from obp.api import API, APIError
|
||||
|
||||
@ -156,9 +156,12 @@
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">{% trans "Verb Select" %}</th>
|
||||
<th scope="col">{% trans "URL" %}</th>
|
||||
<th scope="col" class="col-2">{% trans "URL" %}</th>
|
||||
<th scope="col">{% trans "Source IP" %}</th>
|
||||
<th scope="col">{% trans "Target IP" %}</th>
|
||||
<th scope="col">{% trans "Date" %}</th>
|
||||
<th scope="col">{% trans "Duration(ms)" %}</th>
|
||||
<th scope="col">{% trans "Response Body" %}</th>
|
||||
<th scope="col">{% trans "Details" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -167,11 +170,12 @@
|
||||
<tr>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td>{{ metric.verb_selection }}</td>
|
||||
<td>
|
||||
{{ metric.url }}
|
||||
</td>
|
||||
<td>{{ metric.url }}</td>
|
||||
<td>{{ metric.source_ip}}</td>
|
||||
<td>{{ metric.target_ip }}</td>
|
||||
<td>{{ metric.date|date:"Y-m-d H:i:s.u" }}</td>
|
||||
<td>{{ metric.duration }}</td>
|
||||
<td>{{ metric.response_body }}</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>{% trans "User Name" %}: {{ metric.user_name }}</li>
|
||||
|
||||
@ -43,7 +43,7 @@ class API(object):
|
||||
self.start_session(session_data)
|
||||
self.session_data = session_data
|
||||
|
||||
def call(self, method='GET', url='', payload=None, version=settings.API_ROOT['v500']):
|
||||
def call(self, method='GET', url='', payload=None, version=settings.API_ROOT[settings.API_ROOT_KEY]):
|
||||
"""Workhorse which actually calls the API"""
|
||||
log(logging.INFO, '{} {}'.format(method, url))
|
||||
if payload:
|
||||
@ -64,7 +64,7 @@ class API(object):
|
||||
response.execution_time = elapsed
|
||||
return response
|
||||
|
||||
def get(self, urlpath='', version=settings.API_ROOT['v500']):
|
||||
def get(self, urlpath='', version=settings.API_ROOT[settings.API_ROOT_KEY]):
|
||||
"""
|
||||
Gets data from the API
|
||||
|
||||
@ -77,7 +77,7 @@ class API(object):
|
||||
else:
|
||||
return response
|
||||
|
||||
def delete(self, urlpath, version=settings.API_ROOT['v500']):
|
||||
def delete(self, urlpath, version=settings.API_ROOT[settings.API_ROOT_KEY]):
|
||||
"""
|
||||
Deletes data from the API
|
||||
|
||||
@ -87,7 +87,7 @@ class API(object):
|
||||
response = self.call('DELETE', url)
|
||||
return self.handle_response(response)
|
||||
|
||||
def post(self, urlpath, payload, version=settings.API_ROOT['v500']):
|
||||
def post(self, urlpath, payload, version=settings.API_ROOT[settings.API_ROOT_KEY]):
|
||||
"""
|
||||
Posts data to given urlpath with given payload
|
||||
|
||||
@ -97,7 +97,7 @@ class API(object):
|
||||
response = self.call('POST', url, payload)
|
||||
return self.handle_response(response)
|
||||
|
||||
def put(self, urlpath, payload, version=settings.API_ROOT['v500']):
|
||||
def put(self, urlpath, payload, version=settings.API_ROOT[settings.API_ROOT_KEY]):
|
||||
"""
|
||||
Puts data on given urlpath with given payload
|
||||
|
||||
|
||||
@ -133,5 +133,5 @@
|
||||
|
||||
|
||||
{% block extracss %}
|
||||
<link href="{% static 'users/css/users.css' %}" rel="stylesheet">
|
||||
<link href="{% static 'users/css/users.css' %}" rel="stylesheet">
|
||||
{% endblock extracss %}
|
||||
|
||||
@ -4,9 +4,10 @@ URLs for users app
|
||||
"""
|
||||
|
||||
from django.conf.urls import url
|
||||
from django.urls import path
|
||||
|
||||
from .views import IndexView, DetailView, MyDetailView, DeleteEntitlementView, InvitationView, UserStatusUpdateView, \
|
||||
ExportCsvView
|
||||
ExportCsvView, AutocompleteFieldView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^all$',
|
||||
@ -29,5 +30,5 @@ urlpatterns = [
|
||||
name='user-status-update'),
|
||||
url(r'^export_csv$',
|
||||
ExportCsvView.as_view(),
|
||||
name='export-csv-users')
|
||||
name='export-csv-users'),
|
||||
]
|
||||
|
||||
@ -5,7 +5,7 @@ Views of users app
|
||||
import datetime
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.http import HttpResponseRedirect, HttpResponse
|
||||
from django.http import HttpResponseRedirect, HttpResponse, JsonResponse
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.views.generic import FormView, TemplateView, View
|
||||
|
||||
@ -24,7 +24,6 @@ class FilterRoleName(BaseFilter):
|
||||
]]
|
||||
return filtered
|
||||
|
||||
|
||||
class FilterEmail(BaseFilter):
|
||||
"""Filter users by email address"""
|
||||
filter_type = 'email'
|
||||
@ -439,3 +438,22 @@ class ExportCsvView(LoginRequiredMixin, View):
|
||||
writer.writerow([user['username'], user['user_id'], user['email'], user['provider_id'], user['provider'],
|
||||
user['last_marketing_agreement_signed_date']])
|
||||
return response
|
||||
|
||||
# This below code is not yet working, it is intended to provide a json list of results to feed to jquery-ui autocomplete feature
|
||||
|
||||
class AutocompleteFieldView(View):
|
||||
"""Autocompletes a Field Form based on what endpoint the field is filtering"""
|
||||
def autocomplete_form_field(self, request, *args, **kwargs):
|
||||
api = API(self.request.session.get('obp'))
|
||||
term = self.request.GET.get('term', '')
|
||||
try:
|
||||
urlpath = '/roles'
|
||||
response = api.get(urlpath)
|
||||
if 'code' in response and response['code'] >= 400:
|
||||
messages.error(self.request, response['message'])
|
||||
else:
|
||||
suggestions = response.json()
|
||||
return JsonResponse(suggestions, safe=False)
|
||||
except APIError as err:
|
||||
messages.error(self.request, err)
|
||||
return [], []
|
||||
Loading…
Reference in New Issue
Block a user