login2
This commit is contained in:
36
authlogin/api.php
Normal file
36
authlogin/api.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// uncomment the lines below when running in stand-alone mode:
|
||||||
|
|
||||||
|
// for token+session based authentication (see "login_token.html" + "login_token.php"):
|
||||||
|
|
||||||
|
/*
|
||||||
|
require 'auth.php';
|
||||||
|
$auth = new PHP_API_AUTH(array(
|
||||||
|
'secret'=>'someVeryLongPassPhraseChangeMe',
|
||||||
|
));
|
||||||
|
if ($auth->executeCommand()) exit(0);
|
||||||
|
if (empty($_SESSION['user']) || !$auth->hasValidCsrfToken()) {
|
||||||
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// for form+session based authentication (see "login.html"):
|
||||||
|
|
||||||
|
require 'auth.php';
|
||||||
|
$auth = new PHP_API_AUTH(array(
|
||||||
|
'authenticator'=>function($user,$pass){ if ($user=='admin' && $pass=='admin') $_SESSION['user']=$user; }
|
||||||
|
));
|
||||||
|
if ($auth->executeCommand()) exit(0);
|
||||||
|
if (empty($_SESSION['user']) || !$auth->hasValidCsrfToken()) {
|
||||||
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// include your api code here:
|
||||||
|
//
|
||||||
|
// see: https://github.com/mevdschee/php-crud-api
|
||||||
|
//
|
||||||
|
// placeholder for testing:
|
||||||
|
// echo 'Access granted!';
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<form method="post" action="api.php/">
|
<form method="post" action="loginInterface.php/">
|
||||||
<input name="username" value="admin"/>
|
<input name="username" value="admin"/>
|
||||||
<input name="password" value="admin"/>
|
<input name="password" value="admin"/>
|
||||||
<input type="submit" value="ok">
|
<input type="submit" value="ok">
|
||||||
2787
authlogin/loginInterface.php
Normal file
2787
authlogin/loginInterface.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// uncomment the lines below when running in stand-alone mode:
|
|
||||||
|
|
||||||
// for token+session based authentication (see "login_token.html" + "login_token.php"):
|
|
||||||
|
|
||||||
// require 'auth.php';
|
|
||||||
// $auth = new PHP_API_AUTH(array(
|
|
||||||
// 'secret'=>'someVeryLongPassPhraseChangeMe',
|
|
||||||
// ));
|
|
||||||
// if ($auth->executeCommand()) exit(0);
|
|
||||||
// if (empty($_SESSION['user']) || !$auth->hasValidCsrfToken()) {
|
|
||||||
// header('HTTP/1.0 401 Unauthorized');
|
|
||||||
// exit(0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// for form+session based authentication (see "login.html"):
|
|
||||||
|
|
||||||
// require 'auth.php';
|
|
||||||
// $auth = new PHP_API_AUTH(array(
|
|
||||||
// 'authenticator'=>function($user,$pass){ if ($user=='admin' && $pass=='admin') $_SESSION['user']=$user; }
|
|
||||||
// ));
|
|
||||||
// if ($auth->executeCommand()) exit(0);
|
|
||||||
// if (empty($_SESSION['user']) || !$auth->hasValidCsrfToken()) {
|
|
||||||
// header('HTTP/1.0 401 Unauthorized');
|
|
||||||
// exit(0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// include your api code here:
|
|
||||||
//
|
|
||||||
// see: https://github.com/mevdschee/php-crud-api
|
|
||||||
//
|
|
||||||
// placeholder for testing:
|
|
||||||
// echo 'Access granted!';
|
|
||||||
Reference in New Issue
Block a user