Skip to content
This repository was archived by the owner on Jan 26, 2025. It is now read-only.

Commit bd1dc57

Browse files
brettererLukeTowersaskourascoderintheryevijetmahabaleshwar-okta
authored
Release 1.3.0 (#121)
Co-authored-by: Luke Towers <[email protected]> Co-authored-by: Andrea <[email protected]> Co-authored-by: Kevin <[email protected]> Co-authored-by: Vijet Mahabaleshwar <[email protected]>
1 parent 569ccd4 commit bd1dc57

23 files changed

+3869
-1108
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
OKTA_CLIENT_CLIENTID=
2+
OKTA_CLIENT_SCOPES=
3+
OKTA_CLIENT_PRIVATEKEY=

.github/workflows/stale.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Mark stale issues and pull requests
2+
3+
on:
4+
schedule:
5+
- cron: "30 1 * * *"
6+
7+
jobs:
8+
stale:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/stale@v3
14+
with:
15+
repo-token: ${{ secrets.GITHUB_TOKEN }}
16+
stale-issue-message: 'This issue has been marked stale because there has been no activity within the last 14 days. To keep this issue active, remove the `stale` label.'
17+
stale-pr-message: 'This PR has been marked stale because there has been no activity within the last 28 days. To keep this PR active, remove the `stale` label.'
18+
days-before-issue-stale: 14
19+
days-before-pr-stale: 28
20+
days-before-close: -1
21+
exempt-issue-labels: 'no-stalebot'
22+
exempt-pr-labels: 'no-stalebot'
23+
stale-issue-label: 'stale'
24+
stale-pr-label: 'stale'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
examples
33
phpunit.xml
44
.phpunit.result.cache
5+
.env
6+
.vscode

.travis.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ before_script:
1515
- mkdir -p ~/.phpenv/versions/$(phpenv version-name)/etc
1616
- mkdir -p ~/.okta
1717
script:
18-
- if [[ $TRAVIS_EVENT_TYPE != "cron" ]]; then vendor/bin/phpunit --verbose --coverage-clover build/logs/clover.xml; fi
18+
- if [[ $TRAVIS_EVENT_TYPE != "cron" ]]; then XDEBUG_MODE=coverage vendor/bin/phpunit --verbose --coverage-clover build/logs/clover.xml; fi
1919
- if [[ $TRAVIS_EVENT_TYPE = "cron" ]]; then bash ./scripts/cron-test.sh; fi
2020
after_success:
2121
- if [[ $COVERAGE = 'true' ]]; then bash <(curl -s https://codecov.io/bash); fi
@@ -31,7 +31,7 @@ deploy:
3131
3232
name: PHP Deployment Bot
3333
on:
34-
php: 7.1
34+
php: 8.0
3535
condition: "$DEPLOY_DOCS = true"
3636
tags: true
3737
- provider: pages
@@ -41,23 +41,23 @@ deploy:
4141
4242
name: PHP Deployment Bot
4343
on:
44-
php: 7.1
44+
php: 8.0
4545
condition: "$DEPLOY_DOCS = true"
4646
branch: develop
4747
matrix:
4848
include:
49-
- php: 7.2
50-
env: SETUP=lowest
51-
- php: 7.2
52-
env: SETUP=stable
53-
- php: 7.3
54-
env: SETUP=lowest
5549
- php: 7.3
50+
env: SETUP=stable
51+
- php: 7.4
5652
env:
57-
- COVERAGE=true
5853
- SETUP=stable
5954
- DEPLOY_DOCS=true
55+
- php: 8.0
56+
env:
57+
- COVERAGE=true
58+
- SETUP=stable
6059
notifications:
6160
slack:
61+
if: type = cron
6262
rooms:
6363
secure: pPjnzjBbTuUFSMOKdJQfzQWk8XeCxCg7Y0cRds/DP0YRIDIPOOGzUTWdzJG4oKGmwVFmnlmqGBnC3JaufXmIj0wSw9p/YmAOV9cdaZ6ZaqpqghL6EnN2y3M5jMkmTq7A1vAAvPC8g/NLORiR4fOcgGLzNRgHVVRYIMPE840mWxpEnohfHB/8PquL2/wjlzBuPOJBieq9SAGxb25SPAwMTaP1vewX3CP/zT5IDqqeuULZzR94xNiVIkeYzniDjjmBMh1FYUXbUBhR08jUVLCuvUgk959fpowbWf4UcqwRmcnDGeGYTatvX36MbmLHRhOU1zRvMuMG+uOQwr7kWOqJya3mxcPf6IW0gwXs6TVvruInKjkhsZHyc5oVC4WKgWZ41cd+RRlLbRcLHIvALN1jhLFda/KLpfGUVGFwrVv61kPLGvExMIZMQCxNj7PIr5RZB8faYBfrT3hf2SvG4bDwhdzjc07lqzhGQWvCi12Rc0Yzmo+PuAA4crPCG2OfjAj1U4IyOznvuhXGMfHtQMy5ow6bW9w/q1HTMwNBtswY78hyTetf7FHYmEe29IUnL44Ecv/34FWuY+Hszb1KwPKVdx0g7D9gdWU6sZZSipNrhG84rYIIRTi0zSDlZBS0+0P7WQQsXRJCplQtxHOTgImWDzIXVzqX9kep/AvT0IiO4CY=

README.md

Lines changed: 66 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Okta PHP SDK
1+
# Okta PHP SDK
22

3-
[![Build Status](https://api.travis-ci.org/okta/okta-sdk-php.svg?branch=master,develop)](https://travis-ci.org/okta/okta-sdk-php)
3+
[![Build Status](https://api.travis-ci.org/okta/okta-sdk-php.svg?branch=master,develop)](https://travis-ci.org/okta/okta-sdk-php)
44
[![Codecov](https://img.shields.io/codecov/c/github/okta/okta-sdk-php.svg)](https://codecov.io/github/okta/okta-sdk-php)
55
[![License](https://poser.pugx.org/okta/sdk/license.svg)](https://packagist.org/packages/okta/sdk)
66
[![Support](https://img.shields.io/badge/support-Developer%20Forum-blue.svg)](https://devforum.okta.com/)
@@ -11,18 +11,18 @@
1111
Run `composer require okta/sdk` from the root of your project in terminal, and you are done.
1212

1313
## Client Initialization
14-
Once you have the SDK installed in your project, you will need to instantiate a Client object. We follow the builder
14+
Once you have the SDK installed in your project, you will need to instantiate a Client object. We follow the builder
1515
pattern for building a Client. You can create a Client by calling the ClientBuilder and relying on the ~/.okta/okta
16-
.yaml file for the settings
16+
.yaml file for the settings
1717

1818
```php
1919
$client = (new \Okta\ClientBuilder())
2020
->build();
2121
```
2222

2323
By default, The client builder will look for a file in your home directory with the Okta properties you want to use.
24-
This file should be placed at `~/.okta/okta.yaml`. If at this location, you do not need to define the location
25-
during initialization. If you are unable to place the file there, or you are on a Windows based machine, you will
24+
This file should be placed at `~/.okta/okta.yaml`. If at this location, you do not need to define the location
25+
during initialization. If you are unable to place the file there, or you are on a Windows based machine, you will
2626
have to define the location of this file manually if you want to use the file.
2727

2828
```php
@@ -31,7 +31,7 @@ $client = (new \Okta\ClientBuilder())
3131
->build();
3232
```
3333

34-
If you need to override any of the defaults from your `~/.okta/okta.yaml` file, or you do not have one, you can set
34+
If you need to override any of the defaults from your `~/.okta/okta.yaml` file, or you do not have one, you can set
3535
the properties on the client builder directly. The minimum required properties are your token and organization url.
3636

3737
```php
@@ -42,8 +42,8 @@ $client = (new \Okta\ClientBuilder())
4242
```
4343

4444
### Changing your Http Client Instance
45-
The Okta PHP SDK follows PSR-7 standards for HTTP Messages. We are using Httplug which allows you to change out to
46-
any PSR-7 compliant Http Client. Create a new instance of a `Http\Client\HttpClient`
45+
The Okta PHP SDK follows PSR-7 standards for HTTP Messages. We are using Httplug which allows you to change out to
46+
any PSR-7 compliant Http Client. Create a new instance of a `Http\Client\HttpClient`
4747
implementation and pass it into the client builder.
4848

4949
```php
@@ -52,6 +52,24 @@ $client = (new \Okta\ClientBuilder())
5252
->build();
5353
```
5454

55+
### OAuth 2.0
56+
57+
Okta allows you to interact with Okta APIs using scoped OAuth 2.0 access tokens. Each access token enables the bearer to perform specific actions on specific Okta endpoints, with that ability controlled by which scopes the access token contains.
58+
59+
This SDK supports this feature only for service-to-service applications. Check out [our guides](https://developer.okta.com/docs/guides/implement-oauth-for-okta-serviceapp/overview/) to learn more about how to register a new service application using a private and public key pair.
60+
61+
When using this approach you won't need an API Token because the SDK will request an access token for you. In order to use OAuth 2.0, construct a client instance by passing the following parameters:
62+
63+
```php
64+
$client = (new \Okta\ClientBuilder)
65+
->setAuthorizationMode(new \Okta\Utilities\AuthorizationMode(\Okta\Utilities\AuthorizationMode::PRIVATE_KEY))
66+
->setClientId({{clientId}})
67+
->setScopes("okta.users.read okta.apps.read")
68+
->setPrivateKey("{{PEM PRIVATE KEY BLOCK}}")
69+
->build();
70+
```
71+
72+
5573
## Users
5674
### Finding a user by id
5775
```php
@@ -70,7 +88,7 @@ dump($foundUser);
7088
### Creating a User
7189
```php
7290
$user = new \Okta\Users\User();
73-
$profile = new \Okta\Users\Profile();
91+
$profile = new \Okta\Users\UserProfile();
7492

7593
$profile->setFirstName('John')
7694
->setLastName('User')
@@ -109,7 +127,7 @@ $user->create();
109127
```
110128

111129
### Update user profile
112-
Our SDK allows you to fill in the default profile fields, as well as other dynamic fields that you create in your
130+
Our SDK allows you to fill in the default profile fields, as well as other dynamic fields that you create in your
113131
profile.
114132

115133
```php
@@ -125,7 +143,7 @@ $user = new \Okta\Users\User();
125143
## Pagination and Collections
126144
All of our calls that return a set of items will return a Collection object. The collection object we built on top of
127145
is the tightenco/collect object.
128-
146+
129147
### Getting all users
130148
```php
131149
$users = (new \Okta\Okta)->getUsers();
@@ -141,12 +159,12 @@ $users = (new \Okta\Okta)->getUsers(['query' => ['limit' = 2, 'after' = 2]]);
141159
```
142160

143161
## Caching
144-
The Okta PHP SDK allows any resource with a self link to be cached by default. The SDK uses any PSR-6
145-
caching adaptor that you would like to use. By default, we ship with the
146-
[filesystem cache pool](https://github.com/php-cache/filesystem-adapter) with the
147-
[flysystem memory adaptor](https://github.com/thephpleague/flysystem-memory). By doing this, there is no
148-
need to configure anything, however, if you would like to run with your own Cache strategy, or change how
149-
the default works, you are able to swap out the Cache Manager. Create a new Cache Manager that extends the
162+
The Okta PHP SDK allows any resource with a self link to be cached by default. The SDK uses any PSR-6
163+
caching adaptor that you would like to use. By default, we ship with the
164+
[filesystem cache pool](https://github.com/php-cache/filesystem-adapter) with the
165+
[flysystem memory adaptor](https://github.com/thephpleague/flysystem-memory). By doing this, there is no
166+
need to configure anything, however, if you would like to run with your own Cache strategy, or change how
167+
the default works, you are able to swap out the Cache Manager. Create a new Cache Manager that extends the
150168
base `\Okta\Cache\CacheManager` class, and call the parent `setCachePool()` method. This should be called
151169
with an instance of a PSR-6 compliant cache pool implementation. Once created, you can swap out the manager
152170
using the `ClientBuilder` class
@@ -158,13 +176,38 @@ $clientBuilder = new ClientBuilder();
158176
```
159177

160178
### Contents of the okta.yaml File
161-
```php
179+
```yaml
162180
okta:
163181
client:
164-
orgUrl: null
165-
token: null
182+
orgUrl: "https://{yourOktaDomain}"
183+
token: "{token}"
166184
```
167185
168-
For information on what can go into the query property, visit
169-
[our documentation](https://developer.okta.com/docs/api/resources/users.html#list-users)
186+
When you use OAuth 2.0 the full YAML configuration looks like:
170187
188+
```yaml
189+
okta:
190+
client:
191+
connectionTimeout: 30 # seconds
192+
orgUrl: "https://{yourOktaDomain}"
193+
proxy:
194+
port: null
195+
host: null
196+
username: null
197+
password: null
198+
authorizationMode: "PrivateKey"
199+
clientId: "{yourClientId}"
200+
Scopes:
201+
- scope.1
202+
- scope.2
203+
PrivateKey: "{PEM PRIVATE KEY}"
204+
requestTimeout: 0 # seconds
205+
rateLimit:
206+
maxRetries: 4
207+
```
208+
209+
> You can pass the path to your private key pem file as well instead of copying the pem string into the YAML configuration
210+
> E.g `PrivateKey: /Path/to/privateKey.pem`
211+
212+
For information on what can go into the query property, visit
213+
[our documentation](https://developer.okta.com/docs/api/resources/users.html#list-users)

composer.json

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,26 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^7.2",
13+
"php": "^7.3 | ^8.0",
1414
"psr/http-message": "^1.0",
15-
"php-http/client-common": "^1.1",
16-
"php-http/httplug": "^1.1",
17-
"php-http/message": "^1.5",
18-
"php-http/discovery": "^1.2",
19-
"php-http/curl-client": "^1.7",
20-
"symfony/yaml": "^4.3",
15+
"php-http/client-common": "^2.2",
16+
"php-http/httplug": "^2.2",
17+
"php-http/message": "^1.11",
18+
"php-http/discovery": "^1.13",
19+
"php-http/curl-client": "^2.2",
20+
"symfony/yaml": "^3.2|^4.3",
2121
"nesbot/carbon": "^2.0",
22-
"tightenco/collect": "5.8.31",
23-
"guzzlehttp/psr7": "^1.4",
22+
"illuminate/collections": "8.29.0",
23+
"guzzlehttp/psr7": "1.7.0",
2424
"psr/cache": "^1.0",
2525
"league/flysystem-memory": "^1.0",
26-
"cache/filesystem-adapter": "^1.0"
26+
"cache/filesystem-adapter": "^1.0",
27+
"vlucas/phpdotenv": "^3.3|^4.1",
28+
"lcobucci/jwt": "^4.0@alpha",
29+
"http-interop/http-factory-guzzle": "^1.0"
2730
},
2831
"require-dev": {
29-
"phpunit/phpunit": "^8.0",
32+
"phpunit/phpunit": "^9.0",
3033
"squizlabs/php_codesniffer": "3.*",
3134
"symfony/var-dumper": "^4.3",
3235
"php-http/mock-client": "^1.0"

0 commit comments

Comments
 (0)