Skip to content

Commit

Permalink
Merge pull request #283 from okta/rc_v2_11_1
Browse files Browse the repository at this point in the history
v2.11.1
  • Loading branch information
monde authored Mar 10, 2022
2 parents 65b07d6 + bb60db0 commit d80a944
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 45 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog
Running changelog of releases since `2.0.0-rc.4`

## v2.11.1

### Updates
- Changes `sendTestEmail` response to a `204 no content` instead of `200 success`
- Adds `privateKey` and `teamId` properties to `IdentityProviderCredentialsSigning` to support Apple devices
- Adds to `APPLE` to the enums in `FactorProvider' and `LogCredentialProvider

## v2.11.0

### Updates
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ test\:unit:
@echo "$(COLOR_OK)Running unit tests...$(COLOR_NONE)"
go test -failfast -race ./tests/unit -test.v

test\:integration\:all:
@echo "$(COLOR_OKTA)Running integration tests...$(COLOR_NONE)"
go test -race ./tests/integration -test.v

test\:unit\:all:
@echo "$(COLOR_OK)Running unit tests...$(COLOR_NONE)"
go test -race ./tests/unit -test.v

.PHONY: fmt
fmt: check-fmt # Format the code
@$(GOFMT) -l -w $$(find . -name '*.go' |grep -v vendor) > /dev/null
Expand Down
125 changes: 92 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)
Expand All @@ -127,6 +127,18 @@ example, methods that call the [Users
API](https://developer.okta.com/docs/api/resources/users) are organized under
`client.User`.
## Caching
In the default configuration the client utilizes a memory cache that has a time
to live on its cached values. See [Configuration Setter
Object](#configuration-setter-object) `WithCache(cache bool)`,
`WithCacheTtl(i int32)`, and `WithCacheTti(i int32)`. This helps to
keep HTTP requests to the Okta API at a minimum. In the case where the client
needs to be certain it is accessing recent data; for instance, list items,
delete an item, then list items again; be sure to make use of the refresh next
facility to clear the request cache. See [Refreshing Cache for Specific
Call](#refreshing-cache-for-specific-call). To completely disable the request
memory cache configure the client with `WithCache(false)`.
## Connection Retry / Rate Limiting
Expand Down Expand Up @@ -172,7 +184,7 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)
Expand Down Expand Up @@ -202,14 +214,14 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)

user, resp, err := client.User.GetUser(ctx, "{UserId|Username|Email}")
if err != nil {
fmt.Errorf("Error Getting User: %v", err)
fmt.Printf("Error Getting User: %v\n", err)
}
fmt.Printf("User: %+v\n Response: %+v\n\n",user, resp)
}
Expand All @@ -232,14 +244,14 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)

users, resp, err := client.User.ListUsers(ctx, nil)
if err != nil {
fmt.Errorf("Error Getting Users: %v", err)
fmt.Printf("Error Getting Users: %v\n", err)
}
fmt.Printf("Users: %+v\n Response: %+v\n\n",users, resp)
for index, user := range users {
Expand All @@ -266,7 +278,7 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)
Expand All @@ -275,7 +287,7 @@ func main() {

filteredUsers, resp, err := client.User.ListUsers(ctx, filter)
if err != nil {
fmt.Errorf("Error Getting Users: %v", err)
fmt.Printf("Error Getting Users: %v\n", err)
}

fmt.Printf("Filtered Users: %+v\n Response: %+v\n\n", filteredUsers, resp)
Expand Down Expand Up @@ -304,7 +316,7 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)
Expand Down Expand Up @@ -335,7 +347,7 @@ func main() {

user, resp, err := client.User.CreateUser(ctx, createUserRequest, queryParam)
if err != nil {
fmt.Errorf("Error Creating User: %v", err)
fmt.Printf("Error Creating User: %v\n", err)
}

fmt.Printf("User: %+v\n Response: %+v\n\n", user, resp)
Expand All @@ -360,14 +372,14 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)

userToUpdate, resp, err := client.User.GetUser(ctx, "{userId}")
if err != nil {
fmt.Errorf("Error Getting User to update: %v", err)
fmt.Printf("Error Getting User to update: %v\n", err)
}

fmt.Printf("User to update: %+v\n Response: %+v\n\n", userToUpdate, resp)
Expand All @@ -380,7 +392,7 @@ func main() {

updatedUser, resp, err := client.User.UpdateUser(ctx, userToUpdate.Id, *updateUser, nil)
if err != nil {
fmt.Errorf("Error updating user: %v", err)
fmt.Printf("Error updating user: %v\n", err)
}

fmt.Printf("Updated User: %+v\n Response: %+v\n\n", updatedUser, resp)
Expand Down Expand Up @@ -411,21 +423,21 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)

resp, err := client.User.DeactivateUser(ctx, "00u14ffhw5szVqide0h8", nil)
if err != nil {
fmt.Errorf("Error deactivating user: %v", err)
fmt.Printf("Error deactivating user: %v\n", err)
}

fmt.Printf("Response: %+v\n\n", resp)

resp, err = client.User.DeactivateOrDeleteUser(ctx, "00u14ffhw5szVqide0h8", nil)
if err != nil {
fmt.Errorf("Error deleting user: %v", err)
fmt.Printf("Error deleting user: %v\n", err)
}

fmt.Printf("Response: %+v\n\n", resp)
Expand All @@ -449,14 +461,14 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)

groups, resp, err := client.User.ListUserGroups(ctx, "00u14fg9ff4MExj5f0h8")
if err != nil {
fmt.Errorf("Error getting group list for user: %v", err)
fmt.Printf("Error getting group list for user: %v\n", err)
}

fmt.Printf("Groups: %+v\n Response: %+v\n\n", groups, resp)
Expand Down Expand Up @@ -484,7 +496,7 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)
Expand All @@ -497,7 +509,7 @@ func main() {
}
group, resp, err := client.Group.CreateGroup(ctx, *groupToCreate)
if err != nil {
fmt.Errorf("Error creating group: %v", err)
fmt.Printf("Error creating group: %v\n", err)
}

fmt.Printf("Created Group: %+v\n Response: %+v\n\n", group, resp)
Expand All @@ -521,14 +533,14 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)

resp, err := client.Group.AddUserToGroup(ctx, "{groupId}", "{userId}")
if err != nil {
fmt.Errorf("Error adding user to group: %v", err)
fmt.Printf("Error adding user to group: %v\n", err)
}

fmt.Printf("Response: %+v\n\n", resp)
Expand All @@ -552,14 +564,14 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)

applicationList, resp, err := client.Application.ListApplications(ctx, nil)
if err != nil {
fmt.Errorf("Error listing applications: %v", err)
fmt.Printf("Error listing applications: %v\n", err)
}

fmt.Printf("ApplicationList: %+v\n Response: %+v\n\n", applicationList, resp)
Expand All @@ -571,7 +583,7 @@ func main() {
if app.(*okta.Application).Name == "oidc_client" {
application, resp, err := client.Application.GetApplication(ctx, app.(*okta.Application).Id, okta.NewOpenIdConnectApplication(), nil)
if err != nil {
fmt.Errorf("Error getting application: %v", err)
fmt.Printf("Error getting application: %v\n", err)
}

fmt.Printf("Concrete Application: %+v\n Response: %+v\n\n", application, resp)
Expand All @@ -597,14 +609,14 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)

application, resp, err := client.Application.GetApplication(ctx, "0oaswjmkbtlpBDWpu0h7", okta.NewOpenIdConnectApplication(), nil)
if err != nil {
fmt.Errorf("Error getting application: %v", err)
fmt.Printf("Error getting application: %v\n", err)
}

fmt.Printf("Application: %+v\n Response: %+v\n\n", application, resp)
Expand All @@ -629,7 +641,7 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)
Expand All @@ -650,7 +662,7 @@ func main() {

application, resp, err := client.Application.CreateApplication(ctx, swaApp, nil)
if err != nil {
fmt.Errorf("Error creating application: %v", err)
fmt.Printf("Error creating application: %v\n", err)
}

fmt.Printf("Application: %+v\n Response: %+v\n\n", application, resp)
Expand Down Expand Up @@ -678,7 +690,7 @@ func main() {
)

if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n",ctx, client)
Expand Down Expand Up @@ -722,14 +734,14 @@ func main() {
// create a new request using the cloned request executor
req, err := client.CloneRequestExecutor().NewRequest("POST", url, as)
if err != nil {
fmt.Printf("Error creating new request: %v", err)
fmt.Printf("Error creating new request: %v\n", err)
}

// Make the request
var authServer *AuthorizationServer
resp, err := client.CloneRequestExecutor().Do(ctx, req, &authServer)
if err != nil {
fmt.Printf("Error executing request: %v", err)
fmt.Printf("Error executing request: %v\n", err)
}

fmt.Printf("Authorization Server: %v\n Response: %v\n\n", authServer, resp)
Expand Down Expand Up @@ -819,6 +831,53 @@ variable name with the `_` (underscore) character:
* `OKTA_CLIENT_TOKEN`
* and so on
### Configuration Setter Object
The client is configured with a configuration setter object passed to the `NewClient` function.
| function | description |
|----------|-------------|
| WithCache(cache bool) | Use request memory cache |
| WithCacheManager(cacheManager cache.Cache) | Use custom cache object that implements the `cache.Cache` interface |
| WithCacheTtl(i int32) | Cache time to live in seconds |
| WithCacheTti(i int32) | Cache clean up interval in seconds |
| WithConnectionTimeout(i int64) | HTTP connection timeout in seconds |
| WithProxyPort(i int32) | HTTP proxy port |
| WithProxyHost(host string) | HTTP proxy host |
| WithProxyUsername(username string) | HTTP proxy username |
| WithProxyPassword(pass string) | HTTP proxy password |
| WithOrgUrl(url string) | Okta organization URL |
| WithToken(token string) | Okta API token |
| WithUserAgentExtra(userAgent string) | Append additional information to the HTTP User-Agent |
| WithHttpClient(httpClient http.Client) | Custom net/http client |
| WithHttpClientPtr(httpClient *http.Client) | pointer to custom net/http client |
| WithTestingDisableHttpsCheck(httpsCheck bool) | Disable net/http SSL checks |
| WithRequestTimeout(requestTimeout int64) | HTTP request time out in seconds |
| WithRateLimitMaxRetries(maxRetries int32) | Number of request retries when http request times out |
| WithRateLimitMaxBackOff(maxBackoff int64) | Max amount of time to wait on request back off |
| WithAuthorizationMode(authzMode string) | Okta API auth mode, `SSWS` (Okta based) or `PrivateKey` (OAuth app based) |
| WithClientId(clientId string) | Okta App client id, used with `PrivateKey` oauth auth mode |
| WithScopes(scopes []string) | Okta API app scopes |
| WithPrivateKey(privateKey string) | Private key value |
| WithPrivateKeySigner(signer jose.Signer) | Custom private key signer implementing the `jose.Signer` interface |
### Okta Client Base Configuration
The Okta Client's base configuration starts at
| config setting |
|----------------|
| WithConnectionTimeout(60) |
| WithCache(true) |
| WithCacheTtl(300) |
| WithCacheTti(300),
| WithUserAgentExtra("") |
| WithTestingDisableHttpsCheck(false) |
| WithRequestTimeout(0) |
| WithRateLimitMaxBackOff(30) |
| WithRateLimitMaxRetries(2) |
| WithAuthorizationMode("SSWS") |
## Upgrading to 2.0.x
The main purpose of this version is to include all documented,
Expand Down Expand Up @@ -869,7 +928,7 @@ ctx, client, err := okta.NewClient(ctx,
okta.WithPrivateKey({{PEM PRIVATE KEY BLOCK}}) //when pasting blocks, use backticks and remove all space at beginning of each line.
)
if err != nil {
fmt.Errorf("Error: %v", err)
fmt.Printf("Error: %v\n", err)
}

fmt.Printf("Context: %+v\n Client: %+v\n\n",ctx, client)
Expand Down
Loading

0 comments on commit d80a944

Please sign in to comment.