banner
libxcnya.so

libxcnya.so

Nothing...
telegram
twitter
github
email

Add Cloudflare Turnstile in Typecho Backend

Preface#

Following the last episode, we added reCAPTCHA in the Typecho backend.
Now we will add Cloudflare Turnstile in the Typecho backend.

Getting Started#

First, open Cloudflare and find Turnstile on the left.

![1][1]

Click on this section to Add Site.

![2][2]

Once inside, you can write any site name, enter your domain in the domain field, and select the hosted option for the widget mode.

![3][3]

Then remember these two strings, as you will need them later.

![4][4]

Installation#

There are quite a few changes to make. Theoretically, you could just modify the reCAPTCHA section to make it work, but for the convenience of beginners, I will provide the complete example.

Login Page#

Replace the following content in /admin/login.php

Replace the following content in /var/Widget/Login.php

Replace the following content in /admin/register.php

Replace the following content in /var/Widget/Register.php

Replace the marked fields with your site key and secret key.

Done! Open the website backend, Enjoy!

![5][5]

The colors here are based on the device theme. If you need a fixed color, please refer to the [Turnstile documentation][6] to add the theme tag yourself.

Afterword#

Note: If you are using the Handsome theme like me, to implement front-end login, you need to do the following steps (no need for this step if you are not using the Handsome theme):::

Open the backend, Appearance Settings → Developer Settings → Custom Output HTML Code at the end of body and enter the following content

Then in /usr/themes/handsome/component/headnav.php, around line 369, add the following content on a new line (Handsome 9.0.2)

Replace the marked fields with your site key and secret key.

If user registration is enabled, you also need to add the following content on a new line around line 390 in the same file (Handsome 9.0.2)

Replace the marked fields with your site key and secret key.

If there are other versions with mismatched line numbers and you cannot modify them yourself, please kindly send the PHP file to the site owner via email for assistance.

Great job! Log out of the website, refresh the homepage, Enjoy!

6

Looking Ahead#

Known issues: The Turnstile on the Handsome front-end login remains white in dark mode, and there is currently no solution. Suggestions are welcome in the comments section.
By the way: This verification supports IP authentication, which is theoretically more secure, but the examples in the documentation are not comprehensive enough. If any experts are available, please adapt this feature in the comments section.

This article is synchronized and updated by Mix Space to xLog. The original link is https://blog.nekorua.com/posts/coding/30.html

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.