Skip to content

Commit 946d7f7

Browse files
committed
Initialize README
1 parent 1755e94 commit 946d7f7

File tree

2 files changed

+93
-1
lines changed

2 files changed

+93
-1
lines changed

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# simple-auth-php
2+
3+
## Introduction
4+
5+
This is about the simple authentication API in PHP
6+
7+
## Usage
8+
9+
- Clone this repository via `git` command
10+
11+
```BASH
12+
git clone https://github.com/open-source-contributions/simple-auth-php
13+
```
14+
15+
- Docker image build
16+
17+
```BASH
18+
docker build -t simple_auth_php .
19+
```
20+
21+
- Docker container executing
22+
23+
```BASH
24+
docker run --name=simple_auth_php -d simple_auth_php
25+
```
26+
27+
## Auth API
28+
29+
We assume developers use the `Guzzle, HTTP client` to request this auth API.
30+
31+
- `Login` Action API, it's `login` action request.
32+
33+
```php
34+
use GuzzleHttp\Client;
35+
36+
$client = new Client();
37+
$formParams = [
38+
'form_params' => [
39+
'action' => 'login',
40+
'account' => 'the_account',
41+
'password' => 'the_password',
42+
],
43+
];
44+
45+
$response = $client->request('POST', 'http://localhost:5000', $formParams);
46+
$response = (string) $response->getBody();
47+
$response = json_decode($response, true);
48+
49+
// output: {"result":"Auth is successful.","token":"your_user_token"}
50+
```
51+
52+
- `Logout` Action API, it's `logout` action request.
53+
54+
```php
55+
use GuzzleHttp\Client;
56+
57+
$client = new Client();
58+
$formParams = [
59+
'form_params' => [
60+
'action' => 'logout',
61+
'account' => 'test',
62+
'token' => 'your_user_token',
63+
],
64+
];
65+
66+
$response = $client->request('POST', 'http://localhost:5000', $formParams);
67+
$response = (string) $response->getBody();
68+
$response = json_decode($response, true);
69+
70+
// output: {"result":"Logout is done."}
71+
```
72+
73+
- `Status` Action API, it's `status` action request.
74+
75+
```php
76+
use GuzzleHttp\Client;
77+
78+
$client = new Client();
79+
$formParams = [
80+
'form_params' => [
81+
'action' => 'status',
82+
'account' => 'test',
83+
'token' => 'your_user_token',
84+
],
85+
];
86+
$response = $client->request('POST', 'http://localhost:5000', $formParams);
87+
$response = (string) $response->getBody();
88+
$response = json_decode($response, true);
89+
90+
// output: {"result":"Token is expired. It should be logout."}
91+
// or
92+
// output: {"result":"Token is live."}
93+
```

tests/IndexTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,5 @@ public function testStatusActionOnMissingToken()
264264
$response = json_decode($response, true);
265265

266266
$this->assertSame('Token is missing.', $response['result']);
267-
268267
}
269268
}

0 commit comments

Comments
 (0)