Compare commits

...
3 Commits
Author SHA1 Message Date
pulsar 195f941460 Merge pull request 'Feat/rights from file' (#2) from feat/rights-from-file into main
Reviewed-on: #2
2026-11-08 16:46:57 +00:00
pulsar 9bbf9d90bd Hash user password 2026-11-08 17:46:06 +01:00
pulsar 12f9714e3e Manage rights 2026-11-08 17:45:26 +01:00
5 changed files with 54 additions and 0 deletions

No files matched your search

+25
View File
@@ -8,3 +8,28 @@ radicale_users: []
# Example: # Example:
# - name: toto # - name: toto
# password: <secret> # password: <secret>
# password is either the plain-text password, hashed at deploy time (SHA-512
# crypt, stable per-user salt so the file stays idempotent), or an existing
# htpasswd hash ($apr1$, bcrypt $2y$, $5$, $6$, argon2), written as is.
# Access rights. Empty: built-in "owner_only" model. Otherwise a rights file is
# deployed and used ("from_file"); sections are evaluated in order, the first
# matching one wins. See https://radicale.org/v3.html#authorization-and-rights
radicale_rights: []
# Example (same as owner_only, plus anonymous GET on one calendar):
# - name: root
# user: ".+"
# collection: ""
# permissions: R
# - name: principal
# user: ".+"
# collection: "{user}"
# permissions: RW
# - name: calendars
# user: ".+"
# collection: "{user}/[^/]+"
# permissions: rw
# - name: public
# user: ".*"
# collection: "toto/public"
# permissions: i
+12
View File
@@ -50,6 +50,7 @@
group: "{{ radicale_user }}" group: "{{ radicale_user }}"
mode: u=rw,g=r,o= mode: u=rw,g=r,o=
become: true become: true
diff: false
notify: Restart radicale.service notify: Restart radicale.service
- name: Deploy configuration file - name: Deploy configuration file
@@ -61,3 +62,14 @@
mode: u=rw,g=r,o= mode: u=rw,g=r,o=
become: true become: true
notify: Restart radicale.service notify: Restart radicale.service
- name: Deploy rights file
ansible.builtin.template:
src: rights.j2
dest: "{{ radicale_root_path }}/rights"
owner: root
group: "{{ radicale_user }}"
mode: u=rw,g=r,o=
become: true
when: radicale_rights | length > 0
notify: Restart radicale.service
+5
View File
@@ -12,7 +12,12 @@ stock=utf-8
level=debug level=debug
[rights] [rights]
{% if radicale_rights | length > 0 %}
type=from_file
file={{ radicale_root_path }}/rights
{% else %}
type=owner_only type=owner_only
{% endif %}
[server] [server]
hosts=0.0.0.0:5232, [::]:5232 hosts=0.0.0.0:5232, [::]:5232
+8
View File
@@ -0,0 +1,8 @@
# {{ ansible_managed }}
{% for rule in radicale_rights %}
[{{ rule.name }}]
user: {{ rule.user }}
collection: {{ rule.collection }}
permissions: {{ rule.permissions }}
{% endfor %}
+4
View File
@@ -1,5 +1,9 @@
# {{ ansible_managed }} # {{ ansible_managed }}
{% for user in radicale_users %} {% for user in radicale_users %}
{% if user.password is match('^\$(apr1|2[abxy]?|argon2(i|d|id)|5|6)\$') %}
{{ user.name }}:{{ user.password }} {{ user.name }}:{{ user.password }}
{% else %}
{{ user.name }}:{{ user.password | password_hash('sha512', ((user.name ~ '@' ~ inventory_hostname) | hash('sha256'))[:16]) }}
{% endif %}
{% endfor %} {% endfor %}