Odoo SSO 单点登录

时间:2022-01-19 18:39:43

很多公司会有内部单点登录系统,采用Odoo系统的公司可能就有需要将Odoo接入公司内部的单点登录系统。

实现的思路很简单,由于每个公司的系统不一样,代码仅作示例说明。

首先,重写Odoo登录界面:

<template id="qunar_qsso.login" name="QSSO" inherit_id="web.login">
<xpath expr="//form[@role='form']" position="replace"> <t t-call="web.database_select"/> <!-- 添加一个登录按钮,接入特定sso登录接口-->
........
<p/> <p class="alert alert-danger" t-if="error">
<t t-esc="error"/>
</p>
<p class="alert alert-success" t-if="message">
<t t-esc="message"/>
</p> <input type="hidden" name="redirect" t-att-value="redirect"/> </xpath>
</template>

然后, 重写验证的controller

@http.route('/sso',type="http",auth='public',website=True)
def qsso(self,*args,**kargs):
qcontext = request.params.copy()
if qcontext.get('token'):
#check if the token is valid.
#自己的验证方式和逻辑 url ='/web'
request.params['login']=user
request.params['password']=False
return super(QSSO,self).web_login(*args,**kargs)

界面示例

Odoo SSO 单点登录