Skip to content

Commit 62a5bdd

Browse files
committed
[IMP] auth_oidc: Add AuthOauthProviderGroupLine
Thanks to 4204bd8 @hbrunn & @26hpredraglazarevic
1 parent e6dfb2a commit 62a5bdd

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

auth_oidc/__manifest__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
"summary": "Allow users to login through OpenID Connect Provider",
1717
"external_dependencies": {"python": ["python-jose"]},
1818
"depends": ["auth_oauth"],
19-
"data": ["views/auth_oauth_provider.xml", "data/auth_oauth_data.xml"],
19+
"data": [
20+
"views/auth_oauth_provider.xml",
21+
"data/auth_oauth_data.xml",
22+
"security/ir.model.access.csv",
23+
],
2024
"demo": ["demo/local_keycloak.xml"],
2125
}

auth_oidc/models/auth_oauth_provider.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ class AuthOauthProvider(models.Model):
4747
)
4848
jwks_uri = fields.Char(string="JWKS URL", help="Required for OpenID Connect.")
4949
groups_field = fields.Char(help="Token field that stores the groups' mapping")
50+
group_line_ids = fields.One2many(
51+
"auth.oauth.provider.group_line",
52+
"provider_id",
53+
string="Group maps",
54+
)
5055

5156
@tools.ormcache("self.jwks_uri", "kid")
5257
def _get_keys(self, kid):
@@ -105,3 +110,15 @@ def _decode_id_token(self, access_token, id_token, kid):
105110
if error:
106111
raise error
107112
return {}
113+
114+
115+
class AuthOauthProviderGroupLine(models.Model):
116+
_name = "auth.oauth.provider.group_line"
117+
_description = "Mapping OAuth-provided groups with Odoo groups"
118+
119+
provider_id = fields.Many2one("auth.oauth.provider", required=True)
120+
oauth_group_name = fields.Char(
121+
required=True,
122+
help="Group name as passed in the Access Token from the IdP",
123+
)
124+
group_id = fields.Many2one("res.groups", required=True)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
access_auth_oauth_provider_group_line,auth_oauth_provider,model_auth_oauth_provider_group_line,base.group_system,1,1,1,1

auth_oidc/views/auth_oauth_provider.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
<field name="validation_endpoint" position="after">
1919
<field name="token_endpoint" />
2020
<field name="groups_field" />
21+
<field name="group_line_ids">
22+
<tree>
23+
<field name="oauth_group_name" />
24+
<field name="group_id" />
25+
</tree>
26+
</field>
2127
<field name="jwks_uri" />
2228
</field>
2329
</field>

0 commit comments

Comments
 (0)