Skip to content

Commit 341ef2a

Browse files
update readme and version (#39)
* update readme and version * snake-case-user-agent
1 parent f82adfe commit 341ef2a

File tree

3 files changed

+23
-60
lines changed

3 files changed

+23
-60
lines changed

README.md

Lines changed: 20 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,42 @@
11
<img width="1070" alt="Authsignal" src="https://raw.githubusercontent.com/authsignal/authsignal-php/main/.github/images/authsignal.png">
22

3-
# Authsignal Server PHP SDK
3+
# Authsignal PHP SDK
4+
5+
[![License](https://img.shields.io/packagist/l/authsignal/authsignal-php.svg)](https://github.com/authsignal/authsignal-php/blob/main/LICENSE)
46

57
The official Authsignal PHP library for server-side applications. Use this SDK to easily integrate Authsignal's multi-factor authentication (MFA) and passwordless features into your PHP backend.
68

79
## Installation
810

9-
1. Add Authsignal's library to your project using Composer:
10-
11-
```bash
12-
composer require authsignal/authsignal-php
13-
```
14-
15-
2. Run `composer update` to install the dependencies.
16-
3. Authsignal will now be autoloaded into your project.
17-
18-
## Initialization
19-
20-
Initialize the Authsignal SDK, ensuring you do not hard code the Authsignal Secret Key, always keep this safe.
21-
22-
```php
23-
Authsignal::setApiSecretKey('secretKey');
11+
Using Composer:
12+
```bash
13+
composer require authsignal/authsignal-php
2414
```
2515

26-
You can find your `secretKey` in the [Authsignal Portal](https://portal.authsignal.com/organisations/tenants/api).
27-
28-
## Region selection
29-
30-
Authsignal has multiple api hosting regions. To view your hostname for your tenant, find it in the [Authsignal Portal](https://portal.authsignal.com/organisations/tenants/api).
31-
32-
| Region | Base URL |
33-
| ----------- | ----------------------------------- |
34-
| US (Oregon) | https://signal.authsignal.com/v1 |
35-
| AU (Sydney) | https://au.signal.authsignal.com/v1 |
36-
| EU (Dublin) | https://eu.signal.authsignal.com/v1 |
16+
## Getting Started
3717

38-
You can set the hostname via the following code. If the `setApiUrl` function is not called, the api call defaults to the main Authsignal US region hostname `https://signal.authsignal.com`
39-
40-
An example setting the client to use the AU region.
18+
Initialize the Authsignal client with your secret key from the [Authsignal Portal](https://portal.authsignal.com/) and the API URL for your region.
4119

4220
```php
43-
Authsignal::setApiUrl("https://au.signal.authsignal.com/v1");
44-
```
45-
46-
Alternatively, an environment variable can be used to set the API URL:
21+
use Authsignal;
4722

48-
```bash
49-
AUTHSIGNAL_API_URL=https://au.signal.authsignal.com/v1
23+
// Initialize the client
24+
Authsignal::setApiSecretKey(getenv('AUTHSIGNAL_SECRET_KEY'));
25+
Authsignal::setApiUrl(getenv('AUTHSIGNAL_API_URL')); // Use region-specific URL
5026
```
5127

52-
## Usage
53-
54-
Authsignal's server side signal API has five main calls `track`, `getAction`, `getUser`, `enrollVerifiedAuthenticator`, `verifyChallenge`
55-
56-
For more details on these api calls, refer to our [official PHP SDK docs](https://docs.authsignal.com/sdks/server/php#trackaction).
28+
### API URLs by Region
5729

58-
### Response & Error handling
59-
60-
Example:
61-
62-
```php
63-
$result = Authsignal::updateAction(
64-
userId: $userId,
65-
action: $action,
66-
idempotencyKey: "invalidKey",
67-
attributes: ['state' => 'CHALLENGE_FAILED']
68-
);
69-
70-
# PHP Fatal error: Uncaught AuthsignalNotFoundError: 404 - not_found
71-
```
30+
| Region | API URL |
31+
| ----------- | -------------------------------- |
32+
| US (Oregon) | https://api.authsignal.com/v1 |
33+
| AU (Sydney) | https://au.api.authsignal.com/v1 |
34+
| EU (Dublin) | https://eu.api.authsignal.com/v1 |
7235

7336
## License
7437

75-
The library is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
38+
This SDK is licensed under the [MIT License](LICENSE).
7639

7740
## Documentation
7841

79-
For more information and advanced usage examples, refer to the official [Authsignal Server-Side SDK documentation](https://docs.authsignal.com/sdks/server/overview).
42+
For more information and advanced usage examples, refer to the official [Authsignal Server-Side SDK documentation](https://docs.authsignal.com/sdks/server/overview).

lib/Authsignal/Authsignal.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
abstract class Authsignal
77
{
8-
const VERSION = '4.2.0';
8+
const VERSION = '4.3.0';
99

1010
public static $apiSecretKey;
1111
public static $webhook;
1212

13-
public static $apiUrl = 'https://signal.authsignal.com';
13+
public static $apiUrl = 'https://api.authsignal.com';
1414

1515
private static $curlOpts = array();
1616
private static $validCurlOpts = array(CURLOPT_CONNECTTIMEOUT,

lib/Authsignal/AuthsignalRequestTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function send($method, $url, $payload) {
7777
'Content-Type: application/json',
7878
'Content-Length: ' . (is_null($body) ? 0 : strlen($body)),
7979
'X-Authsignal-Version: ' . Authsignal::VERSION,
80-
'User-Agent: Authsignal PHP'
80+
'User-Agent: authsignal-php'
8181
);
8282
$curlOptions[CURLOPT_HEADER] = true;
8383

0 commit comments

Comments
 (0)