Odoo SSO 單點登錄


很多公司會有內部單點登錄系統,采用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)

 

界面示例

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM