Skip to content

Commit 9c2a934

Browse files
committed
2 parents 05659b7 + 31114b0 commit 9c2a934

1 file changed

Lines changed: 70 additions & 37 deletions

File tree

README.md

Lines changed: 70 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,41 @@
1-
# SecureNative PHP
2-
3-
## Requirements
4-
5-
* PHP version >= 7.2
6-
* Composer
7-
8-
## Installation using composer
9-
1+
<p align="center">
2+
<a href="https://www.securenative.com"><img src="https://user-images.githubusercontent.com/45174009/77826512-f023ed80-7120-11ea-80e0-58aacde0a84e.png" alt="SecureNative Logo"/></a>
3+
</p>
4+
5+
<p align="center">
6+
<b>A Cloud-Native Security Monitoring and Protection for Modern Applications</b>
7+
</p>
8+
<p align="center">
9+
<a href="https://github.com/securenative/securenative-php">
10+
<img alt="Github Actions" src="https://github.com/securenative/securenative-php/workflows/CI/badge.svg">
11+
</a>
12+
<a href="https://codecov.io/gh/securenative/securenative-php">
13+
<img src="https://codecov.io/gh/securenative/securenative-php/branch/master/graph/badge.svg" />
14+
</a>
15+
</p>
16+
<p align="center">
17+
<a href="https://docs.securenative.com">Documentation</a> |
18+
<a href="https://docs.securenative.com/quick-start">Quick Start</a> |
19+
<a href="https://blog.securenative.com">Blog</a> |
20+
<a href="">Chat with us on Slack!</a>
21+
</p>
22+
<hr/>
23+
24+
25+
[SecureNative](https://www.securenative.com/) performs user monitoring by analyzing user interactions with your application and various factors such as network, devices, locations and access patterns to stop and prevent account takeover attacks.
26+
27+
## Install the SDK
28+
29+
When using Composer run the following command:
1030
```shell script
1131
$ composer require securenative/securenative-php
1232
```
1333

14-
## Configuration
15-
16-
#### Using package
17-
```php
18-
require_once __DIR__ . '/vendor/autoload.php';
19-
20-
use SecureNative\sdk\SecureNative;
21-
use SecureNative\sdk\SecureNativeOptions;
22-
use SecureNative\sdk\EventTypes;
23-
```
34+
## Initialize the SDK
2435

25-
#### Initializing SDK
36+
To get your *API KEY*, login to your SecureNative account and go to project settings page:
2637

38+
### Option 1: Initialize via ConfigurationBuilder
2739
```php
2840
$options = new SecureNativeOptions();
2941

@@ -32,19 +44,20 @@ $options->setLogLevel("error");
3244

3345
SecureNative::init("YOUR_API_KEY", $options);
3446
```
47+
### Option 2: Initialize via API Key
3548

36-
| Option | Type | Optional | Default Value | Description |
37-
| -------| -------| -------| -------| -------------------------------------------------|
38-
| apiKey | string | false | none | SecureNative api key |
39-
| apiUrl | string | true | https://api.securenative.com/v1/collector | Default api base address|
40-
| interval| number | true | 1000 | Default interval for SDK to try to persist events|
41-
| maxEvents | number | true | 1000 | Max in-memory events queue|
42-
| timeout | number | true | 1500 | API call timeout in ms|
43-
| autoSend | Boolean | true | true | Should api auto send the events|
44-
45-
## Event tracking
49+
Initialize using default options.
4650

51+
```php
52+
SecureNative::init("YOUR_API_KEY");
4753
```
54+
55+
## Tracking events
56+
57+
Once the SDK has been initialized, tracking requests sent through the SDK
58+
instance.
59+
60+
```php
4861
SecureNative::track(array(
4962
'event' => EventTypes::LOG_IN,
5063
'context' => SecureNative::contextFromContext(),
@@ -60,26 +73,46 @@ SecureNative::track(array(
6073
"prop3" => 3
6174
]
6275
));
76+
```
6377

64-
or
78+
You can also create request context from request:
6579

66-
$ver = SecureNative::verify(array(
67-
'event' => EventTypes::VERIFY,
80+
```php
81+
SecureNative::track(array(
82+
'event' => EventTypes::LOG_IN,
83+
'context' => SecureNativeContext::fromRequest(),
6884
'userId' => '1234',
69-
'context' => SecureNative::contextFromContext()
7085
'userTraits' => (object)[
7186
'name' => 'Your Name',
7287
'email' => 'name@gmail.com'
73-
]
88+
],
89+
));
90+
```
91+
92+
## Verify events
93+
94+
**Example**
95+
96+
```php
97+
$ver = SecureNative::verify(array(
98+
'event' => EventTypes::VERIFY,
99+
'userId' => '27',
100+
'context' => SecureNativeContext::fromRequest(),
101+
'userTraits' => (object)[
102+
'name' => 'Your Name',
103+
'email' => 'name@gmail.com'
104+
]
74105
));
75106
```
76107

77-
Middleware:
108+
## Webhook signature verification
109+
110+
Apply our filter to verify the request is from us, for example:
78111

79112
```php
80113
$verified = SecureNative::getMiddleware()->verifySignature();
81114

82115
if ($verified) {
83116
// Request is trusted (coming from SecureNative)
84117
}
85-
```
118+
```

0 commit comments

Comments
 (0)