Odoo SSO 单点登陆

不少公司会有内部单点登陆系统,采用Odoo系统的公司可能就有须要将Odoo接入公司内部的单点登陆系统。web

实现的思路很简单,因为每一个公司的系统不同,代码仅做示例说明。url

首先,重写Odoo登陆界面:spa

 

<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>

 

而后, 重写验证的controller3d

 

@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)

 

界面示例code

相关文章
相关标签/搜索