Skip to content

Commit

Permalink
Merge pull request #195 from voxpupuli/revert-173-simplify_acl_template
Browse files Browse the repository at this point in the history
Revert "Simplify the acl template"
  • Loading branch information
jyaworski committed Mar 8, 2016
2 parents c2817f0 + 7fba718 commit 801746f
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 29 deletions.
24 changes: 12 additions & 12 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
{'allow' => '*'},
],
},
'by' => {
'group' => ['admin'],
}
'by' => [{
'group' => ['admin']
}]
},
{
'description' => 'Admin, all access',
Expand All @@ -99,9 +99,9 @@
{'allow' => '*'},
],
},
'by' => {
'group' => ['admin'],
}
'by' => [{
'group' => ['admin']
}]
}
]

Expand All @@ -124,9 +124,9 @@
{'allow' => ['read','run']}
],
},
'by' => {
'group' => ['api_token_group'],
}
'by' => [{
'group' => ['api_token_group']
}]
},
{
'description' => 'API Application level access control',
Expand All @@ -144,9 +144,9 @@
{ 'match' => {'path' => '(keys|keys/.*)'}, 'allow' => '*' },
],
},
'by' => {
'group' => ['api_token_group'],
}
'by' => [{
'group' => ['api_token_group']
}]
}
]

Expand Down
29 changes: 14 additions & 15 deletions spec/classes/config/global/aclpolicyfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,36 @@
}
end

default_acl = <<-CONFIG
---
description: "Admin, all access"
default_acl = <<-CONFIG.gsub(/[^\S\n]{10}/, '')
description: 'Admin, all access'
context:
project: ".*"
project: '.*'
for:
resource:
- allow: "*"
- allow: '*'
adhoc:
- allow: "*"
- allow: '*'
job:
- allow: "*"
- allow: '*'
node:
- allow: "*"
- allow: '*'
by:
group:
- admin
- 'admin'
---
description: "Admin, all access"
description: 'Admin, all access'
context:
application: rundeck
application: 'rundeck'
for:
resource:
- allow: "*"
- allow: '*'
project:
- allow: "*"
- allow: '*'
by:
group:
- admin
- 'admin'
CONFIG

it do
Expand Down
44 changes: 42 additions & 2 deletions templates/aclpolicy.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,44 @@
<%- @acl_policies.each do |policy| -%>
<%= YAML.dump(policy) %>
<%- @acl_policies.each_with_index do |policy, index| -%>
description: '<%= policy['description'] %>'
context:
<%= policy['context'].keys[0] %>: '<%= policy['context'].values[0] %>'
for:
<%- policy['for'].each do |resource,kind| -%>
<%= resource %>:
<%- kind.each do |rules| -%>
<%- first_key = true -%>
<%- rules.each do |type, action| -%>
<%- if %w( allow deny ).include?(type) -%>
<% if first_key -%>-<%- else %> <% end -%> <%= type %>: <%- if action.is_a? String -%>'<%= action %>'<%-else-%><%= action %><%-end%>
<%- elsif %w( match equals contains ).include?(type) -%>
<%- action.each do |k,v| -%>
<% if first_key -%>-<%- else %> <% end -%> <%= type %>:
<%- if %w( kind path name group rundeck_server ).include?(k) -%><%=' '%><%- else -%><%-end-%>
<%= k %>: <%- if v.is_a? String -%>'<%= v %>'<%-else-%><%= v %><%-end%>
<%- end -%>
<%- end -%>
<%- first_key = false -%>
<%- end -%>
<%- end -%>
<%- end -%>
by:
<%- policy['by'].each do |by| -%>
<%- if !by['group'].nil? && by['group'] != :undef -%>
group:
<%- by['group'].each do |group| -%>
- '<%= group %>'
<%- end -%>
<%- end -%>
<%- if !by['username'].nil? && by['username'] != :undef -%>
username:
<%- by['username'].each do |username| -%>
- '<%= username %>'
<%- end -%>
<%- end -%>
<%- end -%>
<%- if index != (@acl_policies.length-1) -%>

---

<%- end -%>
<%- end -%>

0 comments on commit 801746f

Please sign in to comment.