BUG | Admin create api key
See original GitHub issueWhen access to route admin/key/edit
, result is an error HTTP 500.
To reproduce
- Start from a new install
- Login as admin
- Go to menu > API Keys
- Click on button “Add Key”
Traceback
Traceback (most recent call last):
File "/opt/PowerDNS-Admin/flask/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/opt/PowerDNS-Admin/flask/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/PowerDNS-Admin/flask/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/opt/PowerDNS-Admin/flask/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/opt/PowerDNS-Admin/flask/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/PowerDNS-Admin/flask/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/opt/PowerDNS-Admin/flask/lib/python3.7/site-packages/flask_login/utils.py", line 272, in decorated_view
return func(*args, **kwargs)
File "/opt/PowerDNS-Admin/powerdnsadmin/decorators.py", line 32, in decorated_function
return f(*args, **kwargs)
File "/opt/PowerDNS-Admin/powerdnsadmin/routes/admin.py", line 161, in edit_key
create=create)
File "/opt/PowerDNS-Admin/flask/lib/python3.7/site-packages/flask/templating.py", line 140, in render_template
ctx.app,
File "/opt/PowerDNS-Admin/flask/lib/python3.7/site-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/opt/PowerDNS-Admin/flask/lib/python3.7/site-packages/jinja2/environment.py", line 1304, in render
self.environment.handle_exception()
File "/opt/PowerDNS-Admin/flask/lib/python3.7/site-packages/jinja2/environment.py", line 925, in handle_exception
raise rewrite_traceback_stack(source=source)
File "/opt/PowerDNS-Admin/powerdnsadmin/templates/admin_edit_key.html", line 2, in top-level template code
{% set active_page = "admin_keys" %}
File "/opt/PowerDNS-Admin/powerdnsadmin/templates/base.html", line 183, in top-level template code
{% block content %}
File "/opt/PowerDNS-Admin/powerdnsadmin/templates/admin_edit_key.html", line 62, in block 'content'
<option {% if domain in key.domains %}selected{% endif %} value="{{ domain.name }}">{{ domain.name }}</option>
jinja2.exceptions.UndefinedError: 'None' has no attribute 'domains'
Workarround
diff --git a/powerdnsadmin/templates/admin_edit_key.html b/powerdnsadmin/templates/admin_edit_key.html
index f1a33a0..d89cad1 100644
--- a/powerdnsadmin/templates/admin_edit_key.html
+++ b/powerdnsadmin/templates/admin_edit_key.html
@@ -59,7 +59,7 @@
<select multiple="multiple" class="form-control" id="key_multi_domain"
name="key_multi_domain">
{% for domain in domains %}
- <option {% if domain in key.domains %}selected{% endif %} value="{{ domain.name }}">{{ domain.name }}</option>
+ <option {% if key and domain in key.domains %}selected{% endif %} value="{{ domain.name }}">{{ domain.name }}</option>
{% endfor %}
</select>
</div>
@@ -165,4 +165,4 @@
</div>
<!-- /.modal-dialog -->
</div>
-{% endblock %}
\ No newline at end of file
+{% endblock %}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
BUG | Admin create api key · Issue #938 · PowerDNS ... - GitHub
Start from a new install · Login as admin · Go to menu > API Keys · Click on button "Add Key" ...
Read more >Getting started with API Keys API - Google Cloud
Click Create and continue. Click the Select a role field and select API Keys Admin. Click Done to finish creating the service account....
Read more >Manage an organization with the admin APIs - Atlassian Support
To create an API key: Go to admin.atlassian.com. Select your organization if you have more than one. Select Settings > API keys.
Read more >Create API key API | Elasticsearch Guide [8.5] | Elastic
The API keys are created by the Elasticsearch API key service, which is automatically enabled. For instructions on disabling the API key service,...
Read more >API keys | Moov Documentation
To create a new API key, navigate to Developers in the Moov Dashboard. Select API keys, where you can view/edit existing keys and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Tchad90 We have same issue. I looked up in code and salt must be a bcrypt’s salt. To generate it, you can do this :
Then add to config file the generated salt.
@RoeiGanor I have added stepsto reproduce, but its really a obvious bug. I didn’t thought it needed more details 😉