Moinmoin wiki is developed in Python. The discuz forum is developed by PHP with an integrated passport interface. Considering Wiki as the main logon interface, using URL transfer authentication to synchronize Forum users is the simplest solution. the problem that the client cannot create a cookie during the Forum passport login process has never been solved, so only two accounts in the system are synchronized, and login still needs to be performed in two systems respectively, although not perfect, it does not affect the actual use. Both systems have cookies. You only need to log in once.
Implementation:
- Disable forum registration. All users can only register from wiki.
- A newly registered user must first log on to the Wiki and call the URL to the Forum passport after passing the Wiki authentication to create a forum account simultaneously.
- You must modify the password on the Wiki and repeat the second item.
CodeModify:
Modify \ Lib \ Site-packages \ moinmoin \ action \ login in moinmoin wiki. PY, the Wiki account password adopts the irreversible encryption method, so the original user password can be obtained only here. after passing the Wiki authentication, the account parameters are composed of URL in the Forum passport format and then passed to the Forum. complete the following code for symmetric encryption.
1 If Request. User. valid: 2 Account = User. User (request, user. getuserid (request, name )) 3 Import Urllib, time, base64, MD5 4 # Authentication Key, custom 5 Mykey = ' 1111111 ' 6 # Select the MD5 encryption mode and the Forum encryption mode. 7 Password = Md5.new (password). hexdigest () 8 Email = Account. Email 9 # System timestamp to prevent expired URLs from disguising 10 Mytime = Time. Time () 11 12 Auth = { ' Time ' : Mytime, ' Username ' : Name, ' Password ' : Password, ' Email ' : Email} 13 # Utf8 encoding is required for processing Chinese user names. For security reasons, you must use your own symmetric encryption method to encrypt this string. 14 Auth = ( ' & ' . Join ([ " % S = % s " % (K, V) For K, V In Auth. Items ()]). encode ( ' Utf8 ' ) 15 # URL verification string 16 Verify = Md5.new (auth + Mykey). hexdigest () 17 ARGs = Urllib. urlencode ({ ' Auth ' : AUTH, ' Verify ' : Verify }) 18 # Generate Forum passport URL 19 Myurl = ' Http://bbs.cwowaddon.com/api/passport.php? Action = login & ' + ARGs 20 21 Request. http_redirect (myurl) 22 Return Request. Finish ()
In the forum, you cannot create a cookie because of login. You need to use the passport function and do not want it to be fully enabled because it will change the registration, login, and logout URL of the Forum. therefore, you need to move your hands and feet to open the xxx_settings table of the database, find a field such as passport_xxx, and modify it:
Passport_expire3600Passport_extcredits0Passport_key1111111Passport_login_urlpassport_logout_urlpassport_register_urlpassport_statusassport_url http://wiki.cwowaddon.com/
Then you need to modify API \ Passport. php
1 If ( $ _ Dcache [ ' Settings ' ] [ ' Passport_status ' ] ! = ' Passport ' ){ 2 Exit ( ' Passport disabled ' ); 3 } Elseif ( $ _ Get [ ' Verify ' ] ! = MD5 ( $ _ Get [ ' Action ' ] . $ _ Get [ ' Auth ' ] . $ _ Get [ ' Forward ' ] . $ _ Dcache [ ' Settings ' ] [ ' Passport_key ' ]) { 4 Exit ( ' Illegal Request ' ); 5 }
Replace the above Code with the following to enable passport.
1 If ( $ _ Get [ ' Verify ' ] ! = MD5 ( $ _ Get [ ' Auth ' ] . $ _ Get [ ' Forward ' ] . $ _ Dcache [ ' Settings ' ] [ ' Passport_key ' ]) { 2 Exit ( ' Illegal Request ' ); 3 }
The following encryption method needs to be completed by yourself, which is the same as the encryption and decryption method in wiki.
1 Function Passport_encrypt ( $ Txt , $ Key ){ 2 // .... 3 } 4 5 Function Passport_decrypt ( $ Txt , $ Key ){ 6 // .... 7 } 8 9 Function Passport_key ( $ Txt , $ Encrypt_key ){ 10 $ Encrypt_key = MD5 ( $ Encrypt_key ); 11 $ CTR = 0 ; 12 $ TMP = '' ; 13 For ( $ I = 0 ; $ I < Strlen ( $ Txt ); $ I ++ ){ 14 $ CTR = $ CTR = Strlen ( $ Encrypt_key ) ? 0 : $ CTR ; 15 $ TMP . = $ Txt [ $ I ] ^ $ Encrypt_key [ $ CTR ++ ]; 16 } 17 Return $ TMP ; 18 }
For more information about passsport, see the discuz Forum Documentation.