[ADD] maintenance_user_ssh_key: create add-on

This commit is contained in:
Stéphan Sainléger
2026-07-07 12:01:42 +02:00
parent ae5977ef81
commit 6e19575012
10 changed files with 190 additions and 0 deletions

2
maintenance_user_ssh_key/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*.*~
*pyc

View File

@@ -0,0 +1,63 @@
==============================
maintenance_user_ssh_key
==============================
This module adds SSH key management to Odoo users. It introduces a new
``ssh.key`` model and a ``ssh_key_ids`` One2many field on ``res.users``.
It allows administrators to associate SSH public keys with each user for
authentication purposes (e.g., remote server access, deployment).
Features:
- **SSH Key model**: Store public keys per user.
- **User integration**: SSH keys are displayed and editable directly on the
user form view.
- **Access control**: All internal users can view SSH keys; only users with
``Settings / Administration`` rights can create, edit, or delete them.
# Installation
Use Odoo normal module installation procedure to install
``maintenance_user_ssh_key``.
This module depends on ``base`` and requires no external Python dependencies.
# Configuration
No specific configuration is required. After installation:
1. Go to *Settings > Users & Companies > Users*.
2. Open any user and navigate to the **SSH Keys** notebook page.
3. Add SSH keys with the public key content.
# Usage
## Managing SSH Keys
- Open a user form and go to the *SSH Keys* tab.
- Click **Add a line** and paste the public key content.
# Bug Tracker
Bugs are tracked on
`our issues website <https://git.elabore.coop/Elabore/maintenance-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and
welcomed feedback.
# Credits
## Contributors
- Stéphan Sainléger
## Funders
The development of this module has been financially supported by:
- Elabore (https://elabore.coop)
## Maintainer
This module is maintained by Elabore.

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -0,0 +1,22 @@
# Copyright 2026 Stéphan Sainléger (Elabore)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "maintenance_user_ssh_key",
"version": "18.0.1.0.0",
"author": "Elabore",
"website": "https://git.elabore.coop/elabore/maintenance-tools",
"maintainer": "Stéphan Sainléger",
"license": "AGPL-3",
"category": "Tools",
"summary": "Manage SSH keys per user.",
"depends": ["base"],
"data": [
"security/ir.model.access.csv",
"views/ssh_key_views.xml",
"views/res_users_views.xml",
],
"installable": True,
"auto_install": False,
"application": False,
}

View File

@@ -0,0 +1,2 @@
from . import ssh_key
from . import res_users

View File

@@ -0,0 +1,14 @@
# Copyright 2026 Stéphan Sainléger (Elabore)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ResUsers(models.Model):
_inherit = "res.users"
ssh_key_ids = fields.One2many(
comodel_name="ssh.key",
inverse_name="user_id",
string="SSH Keys",
)

View File

@@ -0,0 +1,18 @@
# Copyright 2026 Stéphan Sainléger (Elabore)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class SshKey(models.Model):
_name = "ssh.key"
_description = "SSH Key"
key = fields.Text(string="Public Key", required=True)
user_id = fields.Many2one(
comodel_name="res.users",
string="User",
required=True,
ondelete="cascade",
index=True,
)

View File

@@ -0,0 +1,3 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_ssh_key_user,ssh.key.user,model_ssh_key,base.group_user,1,0,0,0
access_ssh_key_manager,ssh.key.manager,model_ssh_key,base.group_system,1,1,1,1
1 id name model_id/id group_id/id perm_read perm_write perm_create perm_unlink
2 access_ssh_key_user ssh.key.user model_ssh_key base.group_user 1 0 0 0
3 access_ssh_key_manager ssh.key.manager model_ssh_key base.group_system 1 1 1 1

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_users_form_ssh_key_inherit" model="ir.ui.view">
<field name="name">res.users.form.ssh.key</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page string="SSH Keys" name="ssh_keys">
<field name="ssh_key_ids">
<list editable="top">
<field name="key"/>
</list>
</field>
</page>
</xpath>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="ssh_key_view_tree" model="ir.ui.view">
<field name="name">ssh.key.tree</field>
<field name="model">ssh.key</field>
<field name="arch" type="xml">
<list editable="top">
<field name="key"/>
<field name="user_id"/>
</list>
</field>
</record>
<record id="ssh_key_view_form" model="ir.ui.view">
<field name="name">ssh.key.form</field>
<field name="model">ssh.key</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="user_id"/>
</group>
<group>
<field name="key" nolabel="1"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="ssh_key_action" model="ir.actions.act_window">
<field name="name">SSH Keys</field>
<field name="res_model">ssh.key</field>
<field name="view_mode">list,form</field>
</record>
<menuitem
id="menu_ssh_key"
action="ssh_key_action"
parent="base.menu_security"
sequence="50"/>
</odoo>