Skip to content

Commit 72e1f3c

Browse files
authored
Merge pull request #1 from akondas/knox-token
Implement Knox Token utility to sign access tokens
2 parents 445ae38 + 01228be commit 72e1f3c

File tree

11 files changed

+3201
-0
lines changed

11 files changed

+3201
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/vendor/
2+
.phpunit.result.cache

.php_cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
return PhpCsFixer\Config::create()
4+
->setRules([
5+
'@PSR2' => true,
6+
'array_syntax' => ['syntax' => 'short'],
7+
'binary_operator_spaces' => ['align_double_arrow' => false, 'align_equals' => false],
8+
'blank_line_after_opening_tag' => true,
9+
'blank_line_before_return' => true,
10+
'cast_spaces' => true,
11+
'concat_space' => ['spacing' => 'none'],
12+
'declare_strict_types' => true,
13+
'method_separation' => true,
14+
'no_blank_lines_after_class_opening' => true,
15+
'no_spaces_around_offset' => ['positions' => ['inside', 'outside']],
16+
'no_unneeded_control_parentheses' => true,
17+
'no_unused_imports' => true,
18+
'phpdoc_align' => true,
19+
'phpdoc_no_access' => true,
20+
'phpdoc_separation' => true,
21+
'pre_increment' => true,
22+
'single_quote' => true,
23+
'trim_array_spaces' => true,
24+
'single_blank_line_before_namespace' => true
25+
])
26+
->setFinder(
27+
PhpCsFixer\Finder::create()
28+
->in(__DIR__ . '/src')
29+
->in(__DIR__ . '/tests')
30+
)
31+
->setRiskyAllowed(true)
32+
->setUsingCache(false)
33+
;

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 Proget Sp. z o.o.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Knox Token
2+
3+
Support library for signing Samsung Knox API access tokens
4+
5+
## Install
6+
7+
```
8+
composer require proget-hq/knox-token
9+
```
10+
11+
## Usage
12+
13+
More info at [Knox Cloud API Integration Guide](https://docs.samsungknox.com/cloud-authentication/api-reference/Default.htm#section/Generate-your-access-token)
14+
15+
### Sign your Client Identifier
16+
17+
```php
18+
use Proget\KnoxToken;
19+
20+
$clientIdentifierJwt = KnoxToken::signClientIdentifier('your-client-identifier', 'keys.json');
21+
```
22+
23+
### Sign your Access Token
24+
25+
```php
26+
use Proget\KnoxToken;
27+
28+
$accessTokenJwt = KnoxToken::signAccessToken('access-token', 'keys.json');
29+
```
30+
31+
## License
32+
33+
MIT

composer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "proget-hq/knox-token",
3+
"description": "Support library for signing Samsung Knox API access tokens",
4+
"type": "library",
5+
"require": {
6+
"ext-json": "*",
7+
"firebase/php-jwt": "^5.0",
8+
"ramsey/uuid": "^3.8"
9+
},
10+
"require-dev": {
11+
"phpunit/phpunit": "^8.2",
12+
"friendsofphp/php-cs-fixer": "^2.15"
13+
},
14+
"license": "MIT",
15+
"authors": [
16+
{
17+
"name": "Arkadiusz Kondas",
18+
"email": "arkadiusz.kondas@gmail.com"
19+
}
20+
],
21+
"autoload": {
22+
"psr-4": {
23+
"Proget\\": "src/"
24+
}
25+
},
26+
"autoload-dev": {
27+
"psr-4": {
28+
"Proget\\Tests\\": "tests/"
29+
}
30+
},
31+
"scripts": {
32+
"check-cs": "php-cs-fixer fix --dry-run",
33+
"fix-cs": "php-cs-fixer fix",
34+
"test": "phpunit"
35+
}
36+
}

0 commit comments

Comments
 (0)