I’m not sure which approach is best but my situation is something need to tie the admin login
with external authentication source. I mean, WP normally is:
wp-admin ---> Check with WP Database ---> Authenticate
Now i need to put an additional tier, in between:
wp-admin ---> Check with WP Database ---> Check with External API (true/false) ---> Authenticate
Means, i need to put an additional Authentication Layer in between (similar logic like, we apply LDAP Authentication Module) which in this case is my own API in-between.
-
So now in WP, where/which user/core file is handling the final
true/false
call returns in its traditional login concept? -
Where do i need to go and make the core hack or modification please?
The login process starts in the
wp-login.php
WordPress file around line 625:The
wp_signon()
function is from thewp-includes/user.php
file.I’m not an expert on this topic, but it looks like you have two choices.
1) Rewrite the
wp_authenticate()
function located in thewp-includes/pluggable.php
.All the functions in
wp-includes/pluggable.php
, check to see if the function already exists before creating the function, so you can add the rewritten function in a theme or a plugin and it will replace the defaultwp_authenticate()
function.2) Add your layer to ‘wp_login’ action hook located near the end of the function.
The ‘wp_login’ action occurs after WordPress is done with all authentication. Use it like this.