Skip to content

Commit 234c98c

Browse files
[Fixes #13009] Add property to evaluate the basic auth
1 parent f51a376 commit 234c98c

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

geonode/services/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Service(ResourceBase):
7979
# Supported Capabilities
8080

8181
def save(self, notify=False, *args, **kwargs):
82-
if kwargs.get("force_insert", False) and self.password:
82+
if kwargs.get("force_insert", False) and self.needs_authentication:
8383
# if is the first creation, we must encrypt the password
8484
self.password = self.set_password(self.password)
8585
return super().save(notify, *args, **kwargs)
@@ -93,6 +93,10 @@ def probe(self):
9393
return self.harvester.remote_available
9494
return False
9595

96+
@property
97+
def needs_authentication(self):
98+
return self.password and self.username
99+
96100
def _get_service_url(self):
97101
parsed_url = urlparse(self.base_url)
98102
encoded_get_args = self.extra_queryparams

geonode/services/templates/services/service_detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h3><strong>{{service.title|default:service.name}}</strong></h3>
1010
<p><strong>{% trans "Abstract" %}:</strong> {{service.abstract}}</p>
1111
<p><strong>{% trans "Keywords" %}:</strong> {{ service.keywords.all|join:", " }}</p>
1212
<p><strong>{% trans "Contact" %}:</strong> <a href="{% url "profile_detail" service.owner.username %}">{{ service.owner }}</a></p>
13-
{% if service.type == 'WMS' and service.username %}
13+
{% if service.type == 'WMS' and service.needs_authentication %}
1414
<p><strong>SERVICE NOTES:</strong> The service is accessed by Basic auth via the user <strong>{{service.username}}</strong></p>
1515
{% endif %}
1616
{% autoescape off %}

geonode/services/templates/services/service_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h2>{% trans "Remote Services" %}</h2>
2929
<a href='{{ service.base_url }}' target="_blank" rel="noopener noreferrer">{{ service.base_url }}</a>
3030
</td>
3131
<td>{{ service.service_type }}</td>
32-
{% if service.username and service.type == 'WMS' %}
32+
{% if service.needs_authentication and service.type == 'WMS' %}
3333
<td>basic auth</td>
3434
{% endif %}
3535
</tr>

0 commit comments

Comments
 (0)