Owncloud Source Code Analysis-5--CAS single-point logon

Source: Internet
Author: User
Tags owncloud
: This article mainly introduces the owncloud source code analysis 5--CAS single-point logon. if you are interested in the PHP Tutorial, refer to it. CAS single sign-on

1. put the CAS package under lib \ private for reference,


2. introduce the handleLogin () method in row 976 of \ owncloud \ lib \ base. php and change the content of this method to the following content:

If (! $ _ REQUEST ['logout']) {OC_App: loadApps (array ('prelogin');} // introduce the cas class library require_once 'private \ CAS. php ';
PhpCAS: setDebug (); // initialize clientphpCAS: client (CAS_VERSION_2_0, '2017. 168.6.101 ', 8080,'/sso '); // if the sso server is in https mode, you need to configure the trust certificate. If the http method is used, comment out this option // phpCAS: setCasServerCACert ('adminca1. crt '); phpCAS: setNoCasServerValidation (); // If you need user ing, you need to set serverCode. if you do not need to, you can comment out // phpCAS: setServerCode ('Pt. jcsj'); // process a single exit request. The first parameter is false, indicating that no client authentication is performed. phpCAS: handleLogoutRequests (false, false); // phpCAS :: setNoCasServerValidation (); // perform authentication phpCAS: forceAuthentication (); if (isset ($ _ REQUEST ['logout']) {phpCAS: logout (); die; // header ("Location: ". OC: $ WEBROOT. (empty (OC: $ WEBROOT )? '/': '');} // Logout if desired // store the following values in the session object, if a user with phpCAS exists, execute local logon // print_r (phpCAS: getAttributes (); die; if (phpCAS: getUser () {if (OC_User :: login (phpCAS: getUser () {$ userId = OC_User: getUser (); // setting up the time zone if (isset ($ _ POST ['timezone-offset ']) {self: $ server-> getSession () -> set ('timezone ', $ _ POST ['timezone-offset']); self: $ server-> getConfig ()-> setUserValue ($ userId, 'Core', 'timezone ', $ _ POST ['timezone']);} self: cleanuplog1_kens ($ userId); if (! Empty ($ _ POST ["remember_login"]) {if (defined ("DEBUG") & DEBUG) {self ::$ server-> getLogger () -> debug ('setting remember login to cooker', array ('app' => 'core');} $ token = \ OC: $ server-> getSecureRandom () -> getMediumStrengthGenerator ()-> generate (32); self: $ server-> getConfig ()-> setUserValue ($ userId, 'login _ token', $ token, time (); OC_User: setMagicInCookie ($ userId, $ token);} else {OC_User: unsetMagicInCookie ();} OC_Util: redirecttodefapage page (); exit ();}}
Modify the checkPassword method (row 158) in \ owncloud \ lib \ private \ user \ database. php:
$ Query = OC_DB: prepare ('select 'uid', 'password' FROM '* PREFIX * users' where lower ('uid') = LOWER (?) '); $ Result = $ query-> execute (array ($ uid); $ row = $ result-> fetchRow (); if ($ row) {// directly return the query information/* $ storedHash = $ row ['password']; $ newHash = ''; if (\ OC: $ server-> getHasher () -> verify ($ password, $ storedHash, $ newHash) {if (! Empty ($ newHash) {$ this-> setPassword ($ uid, $ password);} */return $ row ['uid']; //} else {return false;} return false;

OVER !!

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above introduces the owncloud source code analysis 5--CAS single-point logon, including some content, hope to be helpful to friends interested in PHP tutorials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.