[ADD] maintenance_user_ssh_key: create add-on
This commit is contained in:
2
maintenance_user_ssh_key/.gitignore
vendored
Normal file
2
maintenance_user_ssh_key/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.*~
|
||||
*pyc
|
||||
63
maintenance_user_ssh_key/README.md
Normal file
63
maintenance_user_ssh_key/README.md
Normal 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.
|
||||
1
maintenance_user_ssh_key/__init__.py
Normal file
1
maintenance_user_ssh_key/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
22
maintenance_user_ssh_key/__manifest__.py
Normal file
22
maintenance_user_ssh_key/__manifest__.py
Normal 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,
|
||||
}
|
||||
2
maintenance_user_ssh_key/models/__init__.py
Normal file
2
maintenance_user_ssh_key/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import ssh_key
|
||||
from . import res_users
|
||||
14
maintenance_user_ssh_key/models/res_users.py
Normal file
14
maintenance_user_ssh_key/models/res_users.py
Normal 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",
|
||||
)
|
||||
18
maintenance_user_ssh_key/models/ssh_key.py
Normal file
18
maintenance_user_ssh_key/models/ssh_key.py
Normal 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,
|
||||
)
|
||||
3
maintenance_user_ssh_key/security/ir.model.access.csv
Normal file
3
maintenance_user_ssh_key/security/ir.model.access.csv
Normal 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
|
||||
|
21
maintenance_user_ssh_key/views/res_users_views.xml
Normal file
21
maintenance_user_ssh_key/views/res_users_views.xml
Normal 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>
|
||||
44
maintenance_user_ssh_key/views/ssh_key_views.xml
Normal file
44
maintenance_user_ssh_key/views/ssh_key_views.xml
Normal 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>
|
||||
Reference in New Issue
Block a user