-
-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] auth_oidc_portal: Link OAuth provider on portal user create
- Loading branch information
Christopher Rogos
committed
Nov 14, 2023
1 parent
6c78001
commit 7484abc
Showing
10 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
**This file is going to be generated by oca-gen-addon-readme.** | ||
|
||
*Manual changes will be overwritten.* | ||
|
||
Please provide content in the ``readme`` directory: | ||
|
||
* **DESCRIPTION.rst** (required) | ||
* INSTALL.rst (optional) | ||
* CONFIGURE.rst (optional) | ||
* **USAGE.rst** (optional, highly recommended) | ||
* DEVELOP.rst (optional) | ||
* ROADMAP.rst (optional) | ||
* HISTORY.rst (optional, recommended) | ||
* **CONTRIBUTORS.rst** (optional, highly recommended) | ||
* CREDITS.rst (optional) | ||
|
||
Content of this README will also be drawn from the addon manifest, | ||
from keys such as name, authors, maintainers, development_status, | ||
and license. | ||
|
||
A good, one sentence summary in the manifest is also highly recommended. | ||
|
||
|
||
Automatic changelog generation | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
`HISTORY.rst` can be auto generated using `towncrier <https://pypi.org/project/towncrier>`_. | ||
|
||
Just put towncrier compatible changelog fragments into `readme/newsfragments` | ||
and the changelog file will be automatically generated and updated when a new fragment is added. | ||
|
||
Please refer to `towncrier` documentation to know more. | ||
|
||
NOTE: the changelog will be automatically generated when using `/ocabot merge $option`. | ||
If you need to run it manually, refer to `OCA/maintainer-tools README <https://github.com/OCA/maintainer-tools>`_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2023 glueckkanja AG (https://www.glueckkanja.com) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Authentication OpenID Connect on Portal", | ||
"summary": "Allow portal users to login through OpenID Connect Provider", | ||
"version": "16.0.1.0.0", | ||
"author": ("CRogos (glueckkanja AG), Odoo Community Association (OCA)"), | ||
"license": "AGPL-3", | ||
"maintainers": ["CRogos"], | ||
"category": "hr", | ||
"website": "https://github.com/OCA/server-auth", | ||
"depends": ["auth_oidc", "portal"], | ||
"data": [ | ||
"wizard/portal_wizard_views.xml", | ||
], | ||
"auto_install": False, | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Select a OAuth provider for a portal user. The email address is also used as oauth_id and the first active OAuth provider is selected as default when creating a new portal user. | ||
|
||
.. image:: ..static/description/oauth-portal-user.png |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# See LICENSE file for full copyright and licensing details. | ||
|
||
from . import portal_wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from odoo import fields, models | ||
from odoo.tools import email_normalize | ||
|
||
|
||
class PortalWizardUser(models.TransientModel): | ||
# A model to configure users in the portal wizard. | ||
|
||
_inherit = "portal.wizard.user" | ||
|
||
def _get_default_provider(self): | ||
return self.env["auth.oauth.provider"].search([("enabled", "=", True)], limit=1) | ||
|
||
oauth_provider_id = fields.Many2one( | ||
"auth.oauth.provider", | ||
string="OAuth Provider", | ||
default=_get_default_provider, | ||
domain=[("enabled", "=", True)], | ||
) | ||
|
||
def _create_user(self): | ||
# create a new user for wizard_user.partner_id | ||
# :returns record of res.users | ||
|
||
user = super(PortalWizardUser, self)._create_user() | ||
if self.oauth_provider_id: | ||
user.oauth_uid = email_normalize(self.email).lower() | ||
user.oauth_provider_id = self.oauth_provider_id | ||
|
||
return user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<!-- wizard view --> | ||
<record id="wizard_view" model="ir.ui.view"> | ||
<field name="name">Grant oidc portal access</field> | ||
<field name="model">portal.wizard</field> | ||
<field name="inherit_id" ref="portal.wizard_view" /> | ||
<field name="arch" type="xml"> | ||
<field name="login_date" position="before"> | ||
<field name="oauth_provider_id" /> | ||
</field> | ||
</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../auth_oidc_portal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |