feat: security tab in admin, routes and placeholder view for ee functionality

This commit is contained in:
Andrii Verbytskyi 2024-09-11 10:10:02 +02:00
parent 0943f69ee8
commit e9bf0fab31
5 changed files with 104 additions and 2 deletions

View file

@ -54,7 +54,7 @@ syntax: regexp
^rhodecode\.log$
^rhodecode_dev\.log$
^test\.db$
^venv/
# ac-tests
^acceptance_tests/\.cache.*$

View file

@ -43,7 +43,29 @@ def admin_routes(config):
from rhodecode.apps.admin.views.system_info import AdminSystemInfoSettingsView
from rhodecode.apps.admin.views.user_groups import AdminUserGroupsView
from rhodecode.apps.admin.views.users import AdminUsersView, UsersView
from rhodecode.apps.admin.views.security import AdminSecurityView
# Security EE feature
config.add_route(
'admin_security',
pattern=ADMIN_PREFIX + '/security')
config.add_view(
AdminSecurityView,
attr='security' ,
route_name='admin_security', request_method='GET',
renderer='rhodecode:templates/admin/security/security.mako')
config.add_route(
name='admin_security_update',
pattern=ADMIN_PREFIX + '/security/update')
config.add_view(
AdminSecurityView,
attr='security_update',
route_name='admin_security_update', request_method='POST',
renderer='rhodecode:templates/admin/security/security.mako')
config.add_route(
name='admin_audit_logs',
pattern='/audit_logs')

View file

@ -0,0 +1,39 @@
# Copyright (C) 2010-2024 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
import logging
from rhodecode.apps._base import BaseAppView
from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
log = logging.getLogger(__name__)
class AdminSecurityView(BaseAppView):
def load_default_context(self):
c = self._get_local_tmpl_context()
return c
@LoginRequired()
@HasPermissionAllDecorator('hg.admin')
def security(self):
c = self.load_default_context()
c.active = 'security'
return self._get_template_context(c)

View file

@ -0,0 +1,40 @@
<%inherit file="/base/base.mako"/>
<%def name="title()">
${_('Security Admin')}
%if c.rhodecode_name:
&middot; ${h.branding(c.rhodecode_name)}
%endif
</%def>
<%def name="breadcrumbs_links()"></%def>
<%def name="menu_bar_nav()">
${self.menu_items(active='admin')}
</%def>
<%def name="menu_bar_subnav()">
${self.admin_menu(active='security')}
</%def>
<%def name="main()">
<div class="box">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">${_('Security Audit')}</h3>
</div>
<div class="panel-body">
<h4>${_('This feature is available in RhodeCode EE edition only. Contact {sales_email} to obtain a trial license.').format(sales_email='<a href="mailto:sales@rhodecode.com">sales@rhodecode.com</a>')|n}</h4>
<p>
You can scan your repositories for exposed secrets, passwords, etc
</p>
</div>
</div>
</div>
</%def>

View file

@ -114,6 +114,7 @@
<li class="${h.is_active('repository_groups', active)}"><a href="${h.route_path('repo_groups')}">${_('Repository groups')}</a></li>
<li class="${h.is_active('users', active)}"><a href="${h.route_path('users')}">${_('Users')}</a></li>
<li class="${h.is_active('user_groups', active)}"><a href="${h.route_path('user_groups')}">${_('User groups')}</a></li>
<li class="${h.is_active('security', active)}"><a href="${h.route_path('admin_security')}">${_('Security')}</a></li>
<li class="${h.is_active('artifacts', active)}"><a href="${h.route_path('admin_artifacts')}">${_('Artifacts')}</a></li>
<li class="${h.is_active('automation', active)}"><a href="${h.route_path('admin_automation')}">${_('Automation')}</a></li>
<li class="${h.is_active('scheduler', active)}"><a href="${h.route_path('admin_scheduler')}">${_('Scheduler')}</a></li>