Skip to content

Commit

Permalink
Apply formatting changes
Browse files Browse the repository at this point in the history
Apply formatting changes

Apply formatting changes
  • Loading branch information
wluyima committed Jun 18, 2024
1 parent 6bd6a6b commit bb63584
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
21 changes: 15 additions & 6 deletions auth_oidc/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
from werkzeug.urls import url_decode, url_encode

from odoo import http
from odoo.http import request

from odoo.addons.auth_oauth.controllers.main import OAuthLogin
from odoo.addons.web.controllers.main import Session
from odoo.http import request

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -54,19 +55,27 @@ def list_providers(self):


class OpenIDLogout(Session):

@http.route("/web/session/logout", type="http", auth="none")
def logout(self, redirect="/web/login"):
user = request.env["res.users"].sudo().browse(request.session.uid)
if user.oauth_provider_id.id:
p = request.env["auth.oauth.provider"].sudo().browse(user.oauth_provider_id.id)
p = (

Check warning on line 62 in auth_oidc/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

auth_oidc/controllers/main.py#L62

Added line #L62 was not covered by tests
request.env["auth.oauth.provider"]
.sudo()
.browse(user.oauth_provider_id.id)
)
if p.logout_endpoint:
r = redirect

Check warning on line 68 in auth_oidc/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

auth_oidc/controllers/main.py#L68

Added line #L68 was not covered by tests
if not r.startswith('http:') and not r.startswith('https:'):
r = request.env['ir.config_parameter'].sudo().get_param('web.base.url') + r
if not r.startswith("http:") and not r.startswith("https:"):
r = (

Check warning on line 70 in auth_oidc/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

auth_oidc/controllers/main.py#L70

Added line #L70 was not covered by tests
request.env["ir.config_parameter"]
.sudo()
.get_param("web.base.url")
+ r
)
logout_base_url = p.logout_endpoint
params = {}

Check warning on line 77 in auth_oidc/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

auth_oidc/controllers/main.py#L76-L77

Added lines #L76 - L77 were not covered by tests
if '?' in p.logout_endpoint:
if "?" in p.logout_endpoint:
url_parts = p.logout_endpoint.split("?")
logout_base_url = url_parts[0]
params = url_decode(url_parts[1])
Expand Down
5 changes: 3 additions & 2 deletions auth_oidc/models/auth_oauth_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class AuthOauthProvider(models.Model):
jwks_uri = fields.Char(string="JWKS URL", help="Required for OpenID Connect.")
logout_endpoint = fields.Char(
string="Logout URL",
help="Required for OpenID Connect to logout the user in the authorization provider upon logout in the client, "
"should be the value of end_session_endpoint specified by the authorization provider"
help="Required for OpenID Connect to logout the user in the authorization provider "
"upon logout in the client, should be the value of end_session_endpoint specified by "
"the authorization provider",
)

@tools.ormcache("self.jwks_uri", "kid")
Expand Down

0 comments on commit bb63584

Please sign in to comment.