Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odoo CE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Comunitats Energètiques
Odoo CE
Merge requests
!142
Feature/assign ce admin
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Feature/assign ce admin
feature/assign_ce_admin
into
dev
Overview
43
Commits
46
Pipelines
32
Changes
1
Merged
Benjamí Ramos
requested to merge
feature/assign_ce_admin
into
dev
1 year ago
Overview
43
Commits
46
Pipelines
32
Changes
1
Expand
0
0
Merge request reports
Viewing commit
88f05461
Prev
Next
Show latest version
1 file
+
38
−
26
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
88f05461
Update endpoints on change redirect_admin_url
· 88f05461
konykon
authored
1 year ago
energy_communities/models/auth_oauth_provider.py
+
38
−
26
Options
@@ -18,15 +18,27 @@ class OAuthProvider(models.Model):
is_admin_provider
=
fields
.
Boolean
(
string
=
"
Admin provider
"
)
is_keycloak_provider
=
fields
.
Boolean
(
string
=
"
Keycloak provider
"
)
superuser
=
fields
.
Char
(
string
=
'
Superuser
'
,
help
=
'
A super power user that is able to CRUD users on KC.
'
,
placeholder
=
'
admin
'
,
required
=
False
)
superuser_pwd
=
fields
.
Char
(
string
=
'
Superuser password
'
,
help
=
'"
Superuser
"
user password
'
,
placeholder
=
'
I hope is not
"
admin
"'
,
required
=
False
)
admin_user_endpoint
=
fields
.
Char
(
string
=
'
User admin URL
'
)
root_endpoint
=
fields
.
Char
(
string
=
'
Root URL
'
,
required
=
True
,
default
=
'
http://keycloak-ccee.local:8080/auth/
'
)
realm_name
=
fields
.
Char
(
string
=
'
Realm name
'
,
required
=
True
,
default
=
'
0
'
)
reset_password_endpoint
=
fields
.
Char
(
string
=
'
Reset password URL
'
)
redirect_admin_url
=
fields
.
Char
(
string
=
'
Redirect Link after update password
'
)
superuser
=
fields
.
Char
(
string
=
"
Superuser
"
,
help
=
"
A super power user that is able to CRUD users on KC.
"
,
placeholder
=
"
admin
"
,
required
=
False
,
)
superuser_pwd
=
fields
.
Char
(
string
=
"
Superuser password
"
,
help
=
'"
Superuser
"
user password
'
,
placeholder
=
'
I hope is not
"
admin
"'
,
required
=
False
,
)
admin_user_endpoint
=
fields
.
Char
(
string
=
"
User admin URL
"
)
root_endpoint
=
fields
.
Char
(
string
=
"
Root URL
"
,
required
=
True
,
default
=
"
http://keycloak-ccee.local:8080/auth/
"
,
)
realm_name
=
fields
.
Char
(
string
=
"
Realm name
"
,
required
=
True
,
default
=
"
0
"
)
reset_password_endpoint
=
fields
.
Char
(
string
=
"
Reset password URL
"
)
redirect_admin_url
=
fields
.
Char
(
string
=
"
Redirect Link after update password
"
)
def
validate_admin_provider
(
self
):
if
not
self
.
client_secret
:
@@ -34,28 +46,28 @@ class OAuthProvider(models.Model):
if
not
self
.
superuser_pwd
:
raise
UserError
(
"
Admin provider doesn
'
t have a valid superuser password
"
)
@api.onchange
(
'
root_endpoint
'
,
'
realm_name
'
)
@api.onchange
(
"
root_endpoint
"
,
"
realm_name
"
,
"
redirect_admin_url
"
)
def
_onchange_update_endpoints
(
self
):
if
self
.
is_keycloak_provider
and
self
.
root_endpoint
and
self
.
realm_name
:
self
.
admin_user_endpoint
=
URL_ADMIN_USERS
.
format
(
**
{
'
root_endpoint
'
:
self
.
root_endpoint
,
'
realm_name
'
:
self
.
realm_name
}
)
self
.
auth_endpoint
=
URL_AUTH
.
format
(
**
{
'
root_endpoint
'
:
self
.
root_endpoint
,
'
realm_name
'
:
self
.
realm_name
}
)
self
.
validation_endpoint
=
URL_VALIDATION
.
format
(
**
{
'
root_endpoint
'
:
self
.
root_endpoint
,
'
realm_name
'
:
self
.
realm_name
}
)
self
.
token_endpoint
=
URL_TOKEN
.
format
(
**
{
'
root_endpoint
'
:
self
.
root_endpoint
,
'
realm_name
'
:
self
.
realm_name
}
)
self
.
jwks_uri
=
URL_JWKS
.
format
(
**
{
'
root_endpoint
'
:
self
.
root_endpoint
,
'
realm_name
'
:
self
.
realm_name
}
)
self
.
admin_user_endpoint
=
URL_ADMIN_USERS
.
format
(
**
{
"
root_endpoint
"
:
self
.
root_endpoint
,
"
realm_name
"
:
self
.
realm_name
}
)
self
.
auth_endpoint
=
URL_AUTH
.
format
(
**
{
"
root_endpoint
"
:
self
.
root_endpoint
,
"
realm_name
"
:
self
.
realm_name
}
)
self
.
validation_endpoint
=
URL_VALIDATION
.
format
(
**
{
"
root_endpoint
"
:
self
.
root_endpoint
,
"
realm_name
"
:
self
.
realm_name
}
)
self
.
token_endpoint
=
URL_TOKEN
.
format
(
**
{
"
root_endpoint
"
:
self
.
root_endpoint
,
"
realm_name
"
:
self
.
realm_name
}
)
self
.
jwks_uri
=
URL_JWKS
.
format
(
**
{
"
root_endpoint
"
:
self
.
root_endpoint
,
"
realm_name
"
:
self
.
realm_name
}
)
self
.
reset_password_endpoint
=
URL_RESET_PASSWORD
.
format
(
root_endpoint
=
self
.
root_endpoint
,
realm_name
=
self
.
realm_name
,
kc_uid
=
'
{kc_uid}
'
,
kc_uid
=
"
{kc_uid}
"
,
odoo_url
=
self
.
redirect_admin_url
,
cliend_id
=
self
.
client_id
,
)
Loading