##// END OF EJS Templates
vcs: Minimal change to expose the shadow repository...
vcs: Minimal change to expose the shadow repository Based on my original research, this was the "minimal" starting point. It shows that three concepts are needed for the "repo_name": * From the security standpoint we think of the shadow repository having the same ACL as the target repository of the pull request. This is because the pull request itself is considered to be a part of the target repository. Out of this thought, the variable "acl_repo_name" is used whenever we want to check permissions or when we need the database configuration of the repository. An alternative name would have been "db_repo_name", but the usage for ACL checking is the most important one. * From the web interaction perspective, we need the URL which was originally used to get to the repository. This is because based on this base URL commands can be identified. Especially for Git this is important, so that the commands are correctly recognized. Since the URL is in the focus, this is called "url_repo_name". * Finally we have to deal with the repository on the file system. This is what the VCS layer deal with normally, so this name is called "vcs_repo_name". The original repository interaction is a special case where all three names are the same. When interacting with a pull request, these three names are typically all different. This change is minimal in a sense that it just makes the interaction with a shadow repository barely work, without checking any special constraints yet. This was the starting point for further work on this topic.

File last commit:

r1:854a839a default
r887:175782be default
Show More
default_perms_box.html
156 lines | 7.6 KiB | text/html | HtmlLexer
## snippet for displaying default permission box
## usage:
## <%namespace name="dpb" file="/base/default_perms_box.html"/>
## ${dpb.default_perms_box(<url_to_form>)}
## ${dpb.default_perms_radios()}
<%def name="default_perms_radios(global_permissions_template = False, suffix='', **kwargs)">
<div class="main-content-full-width">
<div class="panel panel-default">
## displayed according to checkbox selection
<div class="panel-heading">
%if not global_permissions_template:
<h3 class="inherit_overlay_default panel-title">${_('Inherited Permissions')}</h3>
<h3 class="inherit_overlay panel-title">${_('Custom Permissions')}</h3>
%else:
<h3 class="panel-title">${_('Default Global Permissions')}</h3>
%endif
</div>
<div class="panel-body">
%if global_permissions_template:
<p>${_('The following options configure the default permissions each user or group will inherit. You can override these permissions for each individual user or user group using individual permissions settings.')}</p>
%endif
<div class="field">
<div class="label">
<label for="default_repo_create${suffix}">${_('Repository Creation')}:</label>
</div>
<div class="radios">
${h.radio('default_repo_create' + suffix, c.repo_create_choices[1][0], label=c.repo_create_choices[1][1], **kwargs)}
${h.radio('default_repo_create' + suffix, c.repo_create_choices[0][0], label=c.repo_create_choices[0][1], **kwargs)}
<span class="help-block">${_('Permission to create root level repositories. When disabled, users can still create repositories inside their own repository groups.')}</span>
</div>
</div>
<div class="field">
<div class="label">
<label for="default_repo_create_on_write${suffix}">${_('Repository Creation With Group Write Access')}:</label>
</div>
<div class="radios">
${h.radio('default_repo_create_on_write' + suffix, c.repo_create_on_write_choices[1][0], label=c.repo_create_on_write_choices[1][1], **kwargs)}
${h.radio('default_repo_create_on_write' + suffix, c.repo_create_on_write_choices[0][0], label=c.repo_create_on_write_choices[0][1], **kwargs)}
<span class="help-block">${_('Write permission given on a repository group will allow creating repositories inside that group.')}</span>
</div>
</div>
<div class="field">
<div class="label">
<label for="default_fork_create${suffix}">${_('Repository Forking')}:</label>
</div>
<div class="radios">
${h.radio('default_fork_create' + suffix, c.fork_choices[1][0], label=c.fork_choices[1][1], **kwargs)}
${h.radio('default_fork_create' + suffix, c.fork_choices[0][0], label=c.fork_choices[0][1], **kwargs)}
<span class="help-block">${_('Permission to create root level repository forks. When disabled, users can still fork repositories inside their own repository groups.')}</span>
</div>
</div>
<div class="field">
<div class="label">
<label for="default_repo_group_create${suffix}">${_('Repository Group Creation')}:</label>
</div>
<div class="radios">
${h.radio('default_repo_group_create' + suffix, c.repo_group_create_choices[1][0], label=c.repo_group_create_choices[1][1], **kwargs)}
${h.radio('default_repo_group_create' + suffix, c.repo_group_create_choices[0][0], label=c.repo_group_create_choices[0][1], **kwargs)}
<span class="help-block">${_('Permission to create root level repository groups. When disabled, repository group admins can still create repository subgroups within their repository groups.')}</span>
</div>
</div>
<div class="field">
<div class="label">
<label for="default_user_group_create${suffix}">${_('User Group Creation')}:</label>
</div>
<div class="radios">
${h.radio('default_user_group_create' + suffix, c.user_group_create_choices[1][0], label=c.user_group_create_choices[1][1], **kwargs)}
${h.radio('default_user_group_create' + suffix, c.user_group_create_choices[0][0], label=c.user_group_create_choices[0][1], **kwargs)}
<span class="help-block">${_('Permission to allow user group creation. When disabled, user group admins can still create subgroups within their user groups.')}</span>
</div>
</div>
<div class="field">
<div class="label">
<label for="default_inherit_default_permissions${suffix}">${_('Inherit Permissions From The Default User')}:</label>
</div>
<div class="radios">
${h.radio('default_inherit_default_permissions' + suffix, c.inherit_default_permission_choices[1][0], label=c.inherit_default_permission_choices[1][1], **kwargs)}
${h.radio('default_inherit_default_permissions' + suffix, c.inherit_default_permission_choices[0][0], label=c.inherit_default_permission_choices[0][1], **kwargs)}
<span class="help-block">${_('Inherit default permissions from the default user. Turn off this option to force explicit permissions for users, even if they are more restrictive than the default user permissions.')}</span>
</div>
</div>
<div class="buttons">
${h.submit('save',_('Save'),class_="btn")}
${h.reset('reset',_('Reset'),class_="btn")}
</div>
</div>
</div>
</div>
</%def>
<%def name="default_perms_box(form_url)">
${h.secure_form(form_url, method='put')}
<div class="form">
<div class="fields">
<div class="field panel panel-default panel-body">
<div class="label label-checkbox">
<label for="inherit_default_permissions">${_('Inherit from default settings')}:</label>
</div>
<div class="checkboxes">
${h.checkbox('inherit_default_permissions',value=True)}
<span class="help-block">
${h.literal(_('Select to inherit permissions from %s permissions settings, '
'including default IP address whitelist and inheritance of \npermission by members of user groups.')
% h.link_to('default user', url('admin_permissions_global')))}
</span>
</div>
</div>
## INHERITED permissions == the user permissions in admin
## if inherit checkbox is set this is displayed in non-edit mode
<div class="inherit_overlay_default">
${default_perms_radios(global_permissions_template = False, suffix='_inherited', disabled="disabled")}
</div>
## CUSTOM permissions
<div class="inherit_overlay">
${default_perms_radios(global_permissions_template = False)}
</div>
</div>
</div>
${h.end_form()}
## JS
<script>
var show_custom_perms = function(inherit_default){
if(inherit_default) {
$('.inherit_overlay_default').show();
$('.inherit_overlay').hide();
}
else {
$('.inherit_overlay').show();
$('.inherit_overlay_default').hide();
}
};
$(document).ready(function(e){
var inherit_checkbox = $('#inherit_default_permissions');
var defaults = inherit_checkbox.prop('checked');
show_custom_perms(defaults);
inherit_checkbox.on('change', function(){
if($(this).prop('checked')){
show_custom_perms(true);
}
else{
show_custom_perms(false);
}
})
})
</script>
</%def>