oktakit 0.1.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/probots.yml +2 -0
- data/.github/workflows/ci.yml +27 -0
- data/.gitignore +1 -1
- data/.rubocop.yml +7 -75
- data/.ruby-version +1 -0
- data/.travis.yml +3 -5
- data/CHANGELOG.md +10 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/Gemfile +6 -4
- data/Gemfile.lock +101 -0
- data/README.md +26 -4
- data/Rakefile +3 -3
- data/dev.yml +1 -1
- data/lib/oktakit/client/apps.rb +16 -0
- data/lib/oktakit/client/group_rules.rb +115 -0
- data/lib/oktakit/client/schemas.rb +64 -0
- data/lib/oktakit/client/users.rb +75 -19
- data/lib/oktakit/client.rb +56 -30
- data/lib/oktakit/error.rb +6 -6
- data/lib/oktakit/response/raise_error.rb +1 -3
- data/lib/oktakit/version.rb +1 -1
- data/lib/oktakit.rb +2 -2
- data/oktakit.gemspec +6 -7
- metadata +18 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: c1fe01d108abe860a7ac491800fbb764ee376f75347117c4e3d190b362f60792
|
|
4
|
+
data.tar.gz: e679278c7cc07668e9d46b8147df2b0b8103190f4e63e4c716d73b0592f27784
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18a8717946d4430395cd9b84b2a5fc2d80af63190fe32bbfafbbdf080add411ffcb98dbc4b19693f0292eba5c644b1db6de742c97c887d77d34401ed60c30014
|
|
7
|
+
data.tar.gz: 57533c0ebcf0369fc7d7d8f58087af0c744a4b5908c9b3ec17c0b8433a3e1ee5cef7768455b73d759c301191ad303508dff944965d83bb734510c020f03f3ddb
|
data/.github/probots.yml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- master
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
name: Ruby ${{ matrix.ruby }}
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
ruby: [2.6, 2.7, 3.0, 3.1]
|
|
18
|
+
steps:
|
|
19
|
+
- name: Check out code
|
|
20
|
+
uses: actions/checkout@v2
|
|
21
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
|
22
|
+
uses: ruby/setup-ruby@v1
|
|
23
|
+
with:
|
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
|
25
|
+
bundler-cache: true
|
|
26
|
+
- name: Ruby tests
|
|
27
|
+
run: bundle exec rspec
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,84 +1,16 @@
|
|
|
1
1
|
# This file strictly follows the rules defined in the Ruby style guide:
|
|
2
2
|
# http://shopify.github.io/ruby-style-guide/
|
|
3
|
+
inherit_gem:
|
|
4
|
+
rubocop-shopify: rubocop.yml
|
|
3
5
|
|
|
4
6
|
AllCops:
|
|
5
|
-
TargetRubyVersion: 2.
|
|
7
|
+
TargetRubyVersion: 2.6
|
|
8
|
+
SuggestExtensions: false
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
# Allow .ruby-version and spec.required_ruby_version to differ
|
|
11
|
+
# to run a newer Ruby version for Rubocop, but don't force users to upgrade
|
|
12
|
+
Gemspec/RequiredRubyVersion:
|
|
8
13
|
Enabled: false
|
|
9
14
|
|
|
10
|
-
Lint/AssignmentInCondition:
|
|
11
|
-
Enabled: false
|
|
12
|
-
|
|
13
|
-
Style/Documentation:
|
|
14
|
-
Enabled: false
|
|
15
|
-
|
|
16
|
-
Style/MultilineOperationIndentation:
|
|
17
|
-
Enabled: false
|
|
18
|
-
|
|
19
|
-
Style/AlignParameters:
|
|
20
|
-
EnforcedStyle: with_fixed_indentation
|
|
21
|
-
|
|
22
|
-
Style/FirstParameterIndentation:
|
|
23
|
-
EnforcedStyle: consistent
|
|
24
|
-
|
|
25
|
-
Style/TrailingCommaInLiteral:
|
|
26
|
-
Enabled: false
|
|
27
|
-
|
|
28
|
-
Style/SignalException:
|
|
29
|
-
EnforcedStyle: only_raise
|
|
30
|
-
|
|
31
|
-
Style/NumericLiterals:
|
|
32
|
-
Enabled: false
|
|
33
|
-
|
|
34
|
-
Style/CaseIndentation:
|
|
35
|
-
IndentWhenRelativeTo: end
|
|
36
|
-
|
|
37
|
-
Style/IndentHash:
|
|
38
|
-
EnforcedStyle: consistent
|
|
39
|
-
|
|
40
|
-
Style/WordArray:
|
|
41
|
-
Enabled: false
|
|
42
|
-
|
|
43
|
-
Metrics/AbcSize:
|
|
44
|
-
Enabled: false
|
|
45
|
-
|
|
46
|
-
Metrics/CyclomaticComplexity:
|
|
47
|
-
Enabled: false
|
|
48
|
-
|
|
49
|
-
Style/StringLiterals:
|
|
50
|
-
Enabled: false
|
|
51
|
-
|
|
52
|
-
Metrics/LineLength:
|
|
53
|
-
Max: 120
|
|
54
|
-
|
|
55
|
-
Metrics/ClassLength:
|
|
56
|
-
Enabled: false
|
|
57
|
-
|
|
58
|
-
Metrics/MethodLength:
|
|
59
|
-
Enabled: false
|
|
60
|
-
|
|
61
|
-
Metrics/ParameterLists:
|
|
62
|
-
Max: 5
|
|
63
|
-
CountKeywordArgs: false
|
|
64
|
-
|
|
65
|
-
Metrics/PerceivedComplexity:
|
|
66
|
-
Enabled: false
|
|
67
|
-
|
|
68
|
-
Lint/EndAlignment:
|
|
69
|
-
AlignWith: variable
|
|
70
|
-
|
|
71
15
|
Style/FrozenStringLiteralComment:
|
|
72
16
|
Enabled: false
|
|
73
|
-
|
|
74
|
-
Style/Alias:
|
|
75
|
-
EnforcedStyle: prefer_alias_method
|
|
76
|
-
|
|
77
|
-
Style/MutableConstant:
|
|
78
|
-
Enabled: false
|
|
79
|
-
|
|
80
|
-
Performance/Casecmp:
|
|
81
|
-
Enabled: false
|
|
82
|
-
|
|
83
|
-
Style/GuardClause:
|
|
84
|
-
Enabled: false
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.6.6
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [v0.3.0] - 2022-01-20
|
|
4
|
+
- [Adds support for Ruby 3](https://github.com/Shopify/oktakit/pull/42)
|
|
5
|
+
- [Adds support for user reactivation endpoint](https://github.com/Shopify/oktakit/pull/47)
|
|
6
|
+
- [Adds support for app user schema operations endpoint](https://github.com/Shopify/oktakit/pull/32)
|
|
7
|
+
- [Makes custom error details available](https://github.com/Shopify/oktakit/pull/48)
|
|
8
|
+
|
|
9
|
+
## [v0.2.1] - 2021-10-14
|
|
10
|
+
- Adds support for [Group Rule operations](https://developer.okta.com/docs/reference/api/groups/#group-rule-operations)
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
|
9
|
+
level of experience, education, socio-economic status, nationality, personal
|
|
10
|
+
appearance, race, religion, or sexual identity and orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at security@shopify.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
|
72
|
+
|
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
|
74
|
+
|
|
75
|
+
For answers to common questions about this code of conduct, see
|
|
76
|
+
https://www.contributor-covenant.org/faq
|
data/Gemfile
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
source 'https://rubygems.org'
|
|
2
3
|
|
|
3
|
-
gem 'rake'
|
|
4
4
|
gem 'byebug'
|
|
5
|
-
gem '
|
|
5
|
+
gem 'rake'
|
|
6
6
|
gem 'yard'
|
|
7
7
|
|
|
8
8
|
group :test do
|
|
9
|
-
gem '
|
|
10
|
-
gem '
|
|
9
|
+
gem 'rubocop'
|
|
10
|
+
gem 'rubocop-shopify', require: false
|
|
11
|
+
gem 'rspec', '~> 3.10'
|
|
12
|
+
gem 'vcr', '~> 6.0'
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
gemspec
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
oktakit (0.3.0)
|
|
5
|
+
sawyer (~> 0.8.1)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
addressable (2.8.0)
|
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
12
|
+
ast (2.4.2)
|
|
13
|
+
byebug (11.1.3)
|
|
14
|
+
diff-lcs (1.4.4)
|
|
15
|
+
faraday (1.9.3)
|
|
16
|
+
faraday-em_http (~> 1.0)
|
|
17
|
+
faraday-em_synchrony (~> 1.0)
|
|
18
|
+
faraday-excon (~> 1.1)
|
|
19
|
+
faraday-httpclient (~> 1.0)
|
|
20
|
+
faraday-multipart (~> 1.0)
|
|
21
|
+
faraday-net_http (~> 1.0)
|
|
22
|
+
faraday-net_http_persistent (~> 1.0)
|
|
23
|
+
faraday-patron (~> 1.0)
|
|
24
|
+
faraday-rack (~> 1.0)
|
|
25
|
+
faraday-retry (~> 1.0)
|
|
26
|
+
ruby2_keywords (>= 0.0.4)
|
|
27
|
+
faraday-em_http (1.0.0)
|
|
28
|
+
faraday-em_synchrony (1.0.0)
|
|
29
|
+
faraday-excon (1.1.0)
|
|
30
|
+
faraday-httpclient (1.0.1)
|
|
31
|
+
faraday-multipart (1.0.3)
|
|
32
|
+
multipart-post (>= 1.2, < 3)
|
|
33
|
+
faraday-net_http (1.0.1)
|
|
34
|
+
faraday-net_http_persistent (1.2.0)
|
|
35
|
+
faraday-patron (1.0.0)
|
|
36
|
+
faraday-rack (1.0.0)
|
|
37
|
+
faraday-retry (1.0.3)
|
|
38
|
+
multipart-post (2.1.1)
|
|
39
|
+
parallel (1.21.0)
|
|
40
|
+
parser (3.0.3.2)
|
|
41
|
+
ast (~> 2.4.1)
|
|
42
|
+
public_suffix (4.0.6)
|
|
43
|
+
rainbow (3.0.0)
|
|
44
|
+
rake (13.0.6)
|
|
45
|
+
regexp_parser (2.2.0)
|
|
46
|
+
rexml (3.2.5)
|
|
47
|
+
rspec (3.10.0)
|
|
48
|
+
rspec-core (~> 3.10.0)
|
|
49
|
+
rspec-expectations (~> 3.10.0)
|
|
50
|
+
rspec-mocks (~> 3.10.0)
|
|
51
|
+
rspec-core (3.10.1)
|
|
52
|
+
rspec-support (~> 3.10.0)
|
|
53
|
+
rspec-expectations (3.10.1)
|
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
55
|
+
rspec-support (~> 3.10.0)
|
|
56
|
+
rspec-mocks (3.10.2)
|
|
57
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
58
|
+
rspec-support (~> 3.10.0)
|
|
59
|
+
rspec-support (3.10.3)
|
|
60
|
+
rubocop (1.23.0)
|
|
61
|
+
parallel (~> 1.10)
|
|
62
|
+
parser (>= 3.0.0.0)
|
|
63
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
64
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
65
|
+
rexml
|
|
66
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
|
67
|
+
ruby-progressbar (~> 1.7)
|
|
68
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
69
|
+
rubocop-ast (1.15.0)
|
|
70
|
+
parser (>= 3.0.1.1)
|
|
71
|
+
rubocop-shopify (2.3.0)
|
|
72
|
+
rubocop (~> 1.22)
|
|
73
|
+
ruby-progressbar (1.11.0)
|
|
74
|
+
ruby2_keywords (0.0.5)
|
|
75
|
+
sawyer (0.8.2)
|
|
76
|
+
addressable (>= 2.3.5)
|
|
77
|
+
faraday (> 0.8, < 2.0)
|
|
78
|
+
unicode-display_width (2.1.0)
|
|
79
|
+
vcr (6.0.0)
|
|
80
|
+
webrick (1.7.0)
|
|
81
|
+
yard (0.9.27)
|
|
82
|
+
webrick (~> 1.7.0)
|
|
83
|
+
|
|
84
|
+
PLATFORMS
|
|
85
|
+
-darwin-21
|
|
86
|
+
arm64-darwin-21
|
|
87
|
+
x86_64-linux
|
|
88
|
+
|
|
89
|
+
DEPENDENCIES
|
|
90
|
+
bundler
|
|
91
|
+
byebug
|
|
92
|
+
oktakit!
|
|
93
|
+
rake
|
|
94
|
+
rspec (~> 3.10)
|
|
95
|
+
rubocop
|
|
96
|
+
rubocop-shopify
|
|
97
|
+
vcr (~> 6.0)
|
|
98
|
+
yard
|
|
99
|
+
|
|
100
|
+
BUNDLED WITH
|
|
101
|
+
2.2.22
|
data/README.md
CHANGED
|
@@ -15,17 +15,34 @@ gem 'oktakit'
|
|
|
15
15
|
|
|
16
16
|
And then execute:
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
```sh
|
|
19
|
+
bundle
|
|
20
|
+
```
|
|
19
21
|
|
|
20
22
|
## Usage
|
|
21
23
|
|
|
22
|
-
`Oktakit` follows similar patterns as found in [`Octokit`](https://github.com/octokit/octokit.rb). So if you are familiar with
|
|
24
|
+
`Oktakit` follows similar patterns as found in [`Octokit`](https://github.com/octokit/octokit.rb). So if you are familiar with Octokit, then you should feel right at home.
|
|
23
25
|
|
|
24
26
|
```ruby
|
|
25
27
|
client = Oktakit.new(token: 't0k3n', organization: 'my-great-org')
|
|
26
28
|
response, http_status = client.list_users
|
|
27
29
|
```
|
|
28
30
|
|
|
31
|
+
To work with the Okta sandbox (`<organization>.oktapreview.com`), set the `api_endpoint`:
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
client = Oktakit.new(token: 't0k3n', api_endpoint: 'https://my-great-org.oktapreview.com/api/v1')
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Pagination
|
|
38
|
+
|
|
39
|
+
Pass the `paginate` flag as options for any `get` action for Oktakit to autopaginate the response for you.
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
client = Oktakit.new(token: 't0k3n', organization: 'my-great-org')
|
|
43
|
+
response, http_status = client.list_users(paginate: true)
|
|
44
|
+
```
|
|
45
|
+
|
|
29
46
|
## Development
|
|
30
47
|
|
|
31
48
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
@@ -41,12 +58,17 @@ To anonymize the VCR data, first setup a real token and endpoint for Okta, such
|
|
|
41
58
|
- Set the `OKTA_TEST_TOKEN` environment variable (this should be real). Don't worry, it is automatically removed.
|
|
42
59
|
- Before committing, change `my-okta` to `okta-test` in `spec_helper.rb` and any VCR Cassettes.
|
|
43
60
|
|
|
44
|
-
The [API Test Client](
|
|
61
|
+
The [API Test Client](https://developer.okta.com/docs/api/getting_started/api_test_client) provided by Okta is also really helpful.
|
|
45
62
|
|
|
46
63
|
## Contributing
|
|
47
64
|
|
|
48
|
-
1. Fork it ( https://github.com/shopify/oktakit/fork )
|
|
65
|
+
1. Fork it ( <https://github.com/shopify/oktakit/fork> )
|
|
49
66
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
50
67
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
51
68
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
52
69
|
5. Create a new Pull Request
|
|
70
|
+
|
|
71
|
+
### Contributor License Agreement
|
|
72
|
+
|
|
73
|
+
New contributors will be required to sign [Shopify's Contributor License Agreement (CLA)](https://cla.shopify.com/).
|
|
74
|
+
There are two versions of the CLA: one for individuals and one for organizations.
|
data/Rakefile
CHANGED
|
@@ -7,13 +7,13 @@ require 'rubocop/rake_task'
|
|
|
7
7
|
RuboCop::RakeTask.new
|
|
8
8
|
|
|
9
9
|
task test: :spec
|
|
10
|
-
task default: [
|
|
10
|
+
task default: %i[spec rubocop]
|
|
11
11
|
|
|
12
12
|
namespace :doc do
|
|
13
13
|
require 'yard'
|
|
14
14
|
YARD::Rake::YardocTask.new do |task|
|
|
15
|
-
task.files = %w
|
|
16
|
-
task.options = %w
|
|
15
|
+
task.files = %w[LICENSE.md lib/**/*.rb]
|
|
16
|
+
task.options = %w[--output-dir doc/yard --markup markdown]
|
|
17
17
|
end
|
|
18
18
|
task default: :yard
|
|
19
19
|
end
|
data/dev.yml
CHANGED
data/lib/oktakit/client/apps.rb
CHANGED
|
@@ -176,6 +176,22 @@ module Oktakit
|
|
|
176
176
|
get("/apps/#{id}/users", options)
|
|
177
177
|
end
|
|
178
178
|
|
|
179
|
+
# List Applications Assigned to User
|
|
180
|
+
#
|
|
181
|
+
# @params user_id [string] User ID
|
|
182
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
183
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
184
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
185
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
186
|
+
# @param options [Hash] Optional. Body params for request.
|
|
187
|
+
# @return [Array<Sawyer::Resource>] Array of Applications Assigned to User
|
|
188
|
+
# @see https://developer.okta.com/docs/api/resources/apps#list-applications-assigned-to-user
|
|
189
|
+
# @example
|
|
190
|
+
# Oktakit.list_applications_assigned_to_user('<user_id>')
|
|
191
|
+
def list_applications_assigned_to_user(user_id, options = {})
|
|
192
|
+
get("/apps?filter=user.id+eq+\"#{user_id}\"&expand=user/#{user_id}", options)
|
|
193
|
+
end
|
|
194
|
+
|
|
179
195
|
# Update Application Credentials for Assigned User
|
|
180
196
|
#
|
|
181
197
|
# @params app_id [string] Application ID
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
module Oktakit
|
|
2
|
+
class Client
|
|
3
|
+
module GroupRules
|
|
4
|
+
# Add Group Rule
|
|
5
|
+
#
|
|
6
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
7
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
8
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
9
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
10
|
+
# @param options [Hash] Optional. Body params for request.
|
|
11
|
+
# @return [Hash<Sawyer::Resource>] The created Group Rule.
|
|
12
|
+
# @see https://developer.okta.com/docs/reference/api/groups/#create-group-rule
|
|
13
|
+
# @example
|
|
14
|
+
# Oktakit.add_group_rule
|
|
15
|
+
def add_group_rule(options = {})
|
|
16
|
+
post('/groups/rules', options)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Get Group Rule
|
|
20
|
+
#
|
|
21
|
+
# @params id [string] Group Rule ID
|
|
22
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
23
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
24
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
25
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
26
|
+
# @param options [Hash] Optional. Body params for request.
|
|
27
|
+
# @return [Hash<Sawyer::Resource>] Fetched Group Rule
|
|
28
|
+
# @see https://developer.okta.com/docs/reference/api/groups/#get-group-rule
|
|
29
|
+
# @example
|
|
30
|
+
# Oktakit.get_group_rule('id')
|
|
31
|
+
def get_group_rule(id, options = {})
|
|
32
|
+
get("/groups/rules/#{id}", options)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# List Group Rules
|
|
36
|
+
#
|
|
37
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
38
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
39
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
40
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
41
|
+
# @param options [Hash] Optional. Body params for request.
|
|
42
|
+
# @return [Array<Sawyer::Resource>] Array of Group Rules
|
|
43
|
+
# @see https://developer.okta.com/docs/reference/api/groups/#list-group-rules
|
|
44
|
+
# @example
|
|
45
|
+
# Oktakit.list_group_rules
|
|
46
|
+
def list_group_rules(options = {})
|
|
47
|
+
get('/groups/rules', options)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Update Group Rule
|
|
51
|
+
#
|
|
52
|
+
# @params id [string] Group Rule ID
|
|
53
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
54
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
55
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
56
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
57
|
+
# @param options [Hash] Optional. Body params for request.
|
|
58
|
+
# @return [Hash<Sawyer::Resource>] Updated Group Rule
|
|
59
|
+
# @see https://developer.okta.com/docs/reference/api/groups/#update-group-rule
|
|
60
|
+
# @example
|
|
61
|
+
# Oktakit.update_group_rule('id')
|
|
62
|
+
def update_group_rule(id, options = {})
|
|
63
|
+
put("/groups/rules/#{id}", options)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Remove Group Rule
|
|
67
|
+
#
|
|
68
|
+
# @params id [string] Group ID
|
|
69
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
70
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
71
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
72
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
73
|
+
# @param options [Hash] Optional. Body params for request.
|
|
74
|
+
# @return HTTP 202 Accepted
|
|
75
|
+
# @see https://developer.okta.com/docs/reference/api/groups/#delete-a-group-rule
|
|
76
|
+
# @example
|
|
77
|
+
# Oktakit.remove_group_rule('id')
|
|
78
|
+
def remove_group_rule(id, options = {})
|
|
79
|
+
delete("/groups/rules/#{id}", options)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Activate Group Rule
|
|
83
|
+
#
|
|
84
|
+
# @params id [string] Group ID
|
|
85
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
86
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
87
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
88
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
89
|
+
# @param options [Hash] Optional. Body params for request.
|
|
90
|
+
# @return HTTP 204 No Content
|
|
91
|
+
# @see https://developer.okta.com/docs/reference/api/groups/#activate-a-group-rule
|
|
92
|
+
# @example
|
|
93
|
+
# Oktakit.activate_group_rule('id')
|
|
94
|
+
def activate_group_rule(id, options = {})
|
|
95
|
+
post("/groups/rules/#{id}/lifecycle/activate", options)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Deactivate Group Rule
|
|
99
|
+
#
|
|
100
|
+
# @params id [string] Group ID
|
|
101
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
102
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
103
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
104
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
105
|
+
# @param options [Hash] Optional. Body params for request.
|
|
106
|
+
# @return HTTP 204 No Content
|
|
107
|
+
# @see https://developer.okta.com/docs/reference/api/groups/#deactivate-a-group-rule
|
|
108
|
+
# @example
|
|
109
|
+
# Oktakit.deactivate_group_rule('id')
|
|
110
|
+
def deactivate_group_rule(id, options = {})
|
|
111
|
+
post("/groups/rules/#{id}/lifecycle/deactivate", options)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -60,6 +60,70 @@ module Oktakit
|
|
|
60
60
|
def remove_property_from_user_profile_schema(options = {})
|
|
61
61
|
post('/meta/schemas/user/default', options)
|
|
62
62
|
end
|
|
63
|
+
|
|
64
|
+
# Get App User Schema
|
|
65
|
+
#
|
|
66
|
+
# @params id [string] Application ID
|
|
67
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
68
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
69
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
70
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
71
|
+
# @param options [Hash] Optional. Body params for request.
|
|
72
|
+
# @return [Hash<Sawyer::Resource>] User Schema
|
|
73
|
+
# @see https://developer.okta.com/docs/reference/api/schemas/#get-app-user-schema
|
|
74
|
+
# @example
|
|
75
|
+
# Oktakit.get_app_user_schema('id')
|
|
76
|
+
def get_app_user_schema(id, options = {})
|
|
77
|
+
get("/meta/schemas/apps/#{id}/default", options)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Add Property to App User Profile Schema
|
|
81
|
+
#
|
|
82
|
+
# @params id [string] Application ID
|
|
83
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
84
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
85
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
86
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
87
|
+
# @param options [Hash] Optional. Body params for request.
|
|
88
|
+
# @return [Hash<Sawyer::Resource>] User Schema
|
|
89
|
+
# @see https://developer.okta.com/docs/reference/api/schemas/#add-property-to-app-user-profile-schema
|
|
90
|
+
# @example
|
|
91
|
+
# Oktakit.add_property_to_app_user_profile_schema('id')
|
|
92
|
+
def add_property_to_app_user_profile_schema(id, options = {})
|
|
93
|
+
post("/meta/schemas/apps/#{id}/default", options)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Update App User Profile Schema property
|
|
97
|
+
#
|
|
98
|
+
# @params id [string] Application ID
|
|
99
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
100
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
101
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
102
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
103
|
+
# @param options [Hash] Optional. Body params for request.
|
|
104
|
+
# @return [Hash<Sawyer::Resource>] User Schema
|
|
105
|
+
# @see https://developer.okta.com/docs/reference/api/schemas/#update-app-user-profile-schema-property
|
|
106
|
+
# @example
|
|
107
|
+
# Oktakit.update_app_user_profile_schema_property('id')
|
|
108
|
+
def update_app_user_profile_schema_property(id, options = {})
|
|
109
|
+
post("/meta/schemas/apps/#{id}/default", options)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Remove property from App User Profile Schema
|
|
113
|
+
#
|
|
114
|
+
# @params id [string] Application ID
|
|
115
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
116
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
117
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
118
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
119
|
+
# @param options [Hash] Optional. Body params for request.
|
|
120
|
+
# @return [Hash<Sawyer::Resource>] User Schema
|
|
121
|
+
# @see https://developer.okta.com/docs/reference/api/schemas/#remove-property-from-app-user-profile-schema
|
|
122
|
+
# @example
|
|
123
|
+
# Oktakit.remove_property_from_app_user_profile_schema('id')
|
|
124
|
+
def remove_property_from_app_user_profile_schema(id, options = {})
|
|
125
|
+
post("/meta/schemas/apps/#{id}/default", options)
|
|
126
|
+
end
|
|
63
127
|
end
|
|
64
128
|
end
|
|
65
129
|
end
|
data/lib/oktakit/client/users.rb
CHANGED
|
@@ -9,7 +9,7 @@ module Oktakit
|
|
|
9
9
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
10
10
|
# @param options [Hash] Optional. Body params for request.
|
|
11
11
|
# @return [Hash<Sawyer::Resource>] Returns the created User.
|
|
12
|
-
# @see
|
|
12
|
+
# @see https://developer.okta.com/docs/api/resources/users#create-user
|
|
13
13
|
# @example
|
|
14
14
|
# Oktakit.create_user
|
|
15
15
|
def create_user(options = {})
|
|
@@ -25,7 +25,7 @@ module Oktakit
|
|
|
25
25
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
26
26
|
# @param options [Hash] Optional. Body params for request.
|
|
27
27
|
# @return [Hash<Sawyer::Resource>] Fetched User
|
|
28
|
-
# @see
|
|
28
|
+
# @see https://developer.okta.com/docs/api/resources/users#get-user
|
|
29
29
|
# @example
|
|
30
30
|
# Oktakit.get_user('id')
|
|
31
31
|
def get_user(id, options = {})
|
|
@@ -40,7 +40,7 @@ module Oktakit
|
|
|
40
40
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
41
41
|
# @param options [Hash] Optional. Body params for request.
|
|
42
42
|
# @return [Array<Sawyer::Resource>] Array of User
|
|
43
|
-
# @see
|
|
43
|
+
# @see https://developer.okta.com/docs/api/resources/users#list-users
|
|
44
44
|
# @example
|
|
45
45
|
# Oktakit.list_users
|
|
46
46
|
def list_users(options = {})
|
|
@@ -54,13 +54,18 @@ module Oktakit
|
|
|
54
54
|
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
55
55
|
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
56
56
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
57
|
+
# @param options[:partial] [Boolean] Indicates a partial update, in which case POST will be used instead of PUT
|
|
57
58
|
# @param options [Hash] Optional. Body params for request.
|
|
58
59
|
# @return [Hash<Sawyer::Resource>] Updated User
|
|
59
|
-
# @see
|
|
60
|
+
# @see https://developer.okta.com/docs/api/resources/users#update-user
|
|
60
61
|
# @example
|
|
61
62
|
# Oktakit.update_user('id')
|
|
62
63
|
def update_user(id, options = {})
|
|
63
|
-
|
|
64
|
+
if options.delete(:partial)
|
|
65
|
+
post("/users/#{id}", options)
|
|
66
|
+
else
|
|
67
|
+
put("/users/#{id}", options)
|
|
68
|
+
end
|
|
64
69
|
end
|
|
65
70
|
|
|
66
71
|
# Update Profile
|
|
@@ -72,7 +77,7 @@ module Oktakit
|
|
|
72
77
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
73
78
|
# @param options [Hash] Optional. Body params for request.
|
|
74
79
|
# @return [Hash<Sawyer::Resource>] Updated User
|
|
75
|
-
# @see
|
|
80
|
+
# @see https://developer.okta.com/docs/api/resources/users#update-profile
|
|
76
81
|
# @example
|
|
77
82
|
# Oktakit.update_profile('id')
|
|
78
83
|
def update_profile(id, options = {})
|
|
@@ -87,7 +92,7 @@ module Oktakit
|
|
|
87
92
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
88
93
|
# @param options [Hash] Optional. Body params for request.
|
|
89
94
|
# @return [Array<Sawyer::Resource>] Array of App Links
|
|
90
|
-
# @see
|
|
95
|
+
# @see https://developer.okta.com/docs/api/resources/users#get-assigned-app-links
|
|
91
96
|
# @example
|
|
92
97
|
# Oktakit.get_assigned_app_links('id')
|
|
93
98
|
def get_assigned_app_links(id, options = {})
|
|
@@ -103,7 +108,7 @@ module Oktakit
|
|
|
103
108
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
104
109
|
# @param options [Hash] Optional. Body params for request.
|
|
105
110
|
# @return [Array<Sawyer::Resource>] Array of Groups
|
|
106
|
-
# @see
|
|
111
|
+
# @see https://developer.okta.com/docs/api/resources/users#get-member-groups
|
|
107
112
|
# @example
|
|
108
113
|
# Oktakit.get_member_groups('id')
|
|
109
114
|
def get_member_groups(id, options = {})
|
|
@@ -119,13 +124,31 @@ module Oktakit
|
|
|
119
124
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
120
125
|
# @param options [Hash] Optional. Body params for request.
|
|
121
126
|
# @return [Hash<Sawyer::Resource>] Returns empty object by default. If sendEmail is false, a user activation link.
|
|
122
|
-
# @see
|
|
127
|
+
# @see https://developer.okta.com/docs/api/resources/users#activate-user
|
|
123
128
|
# @example
|
|
124
129
|
# Oktakit.activate_user('id')
|
|
125
130
|
def activate_user(id, options = {})
|
|
126
131
|
post("/users/#{id}/lifecycle/activate", options)
|
|
127
132
|
end
|
|
128
133
|
|
|
134
|
+
# Reactivate User
|
|
135
|
+
#
|
|
136
|
+
# @params id [string] User ID
|
|
137
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
138
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
139
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
140
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
141
|
+
# @param options [Hash] Optional. Body params for request.
|
|
142
|
+
# @return [Hash<Sawyer::Resource>].
|
|
143
|
+
# @note The user must be in a PROVISIONED status
|
|
144
|
+
# @see https://developer.okta.com/docs/reference/api/users/#reactivate-user
|
|
145
|
+
# @example
|
|
146
|
+
# Oktakit.reactivate_user('id')
|
|
147
|
+
|
|
148
|
+
def reactivate_user(id, options = {})
|
|
149
|
+
post("/users/#{id}/lifecycle/reactivate", options)
|
|
150
|
+
end
|
|
151
|
+
|
|
129
152
|
# Deactivate User
|
|
130
153
|
#
|
|
131
154
|
# @params id [string] User ID
|
|
@@ -135,13 +158,31 @@ module Oktakit
|
|
|
135
158
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
136
159
|
# @param options [Hash] Optional. Body params for request.
|
|
137
160
|
# @return [Hash<Sawyer::Resource>] Returns an empty object.
|
|
138
|
-
# @see
|
|
161
|
+
# @see https://developer.okta.com/docs/api/resources/users#deactivate-user
|
|
139
162
|
# @example
|
|
140
163
|
# Oktakit.deactivate_user('id')
|
|
141
164
|
def deactivate_user(id, options = {})
|
|
142
165
|
post("/users/#{id}/lifecycle/deactivate", options)
|
|
143
166
|
end
|
|
144
167
|
|
|
168
|
+
# Delete User
|
|
169
|
+
#
|
|
170
|
+
# @params id [string] User ID
|
|
171
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
172
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
173
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
174
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
175
|
+
# @param options [Hash] Optional. Body params for the request.
|
|
176
|
+
# @return 204 'No Content'
|
|
177
|
+
# @note Deletes a user permanently. This operation can only be performed on users that have a DEPROVISIONED status. This action cannot be recovered!
|
|
178
|
+
# This operation on a user that hasn't been deactivated causes that user to be deactivated. A second delete operation is required to delete the user.
|
|
179
|
+
# @see https://developer.okta.com/docs/reference/api/users/#delete-user
|
|
180
|
+
# @example
|
|
181
|
+
# Oktakit.delete_user('id')
|
|
182
|
+
def delete_user(id, options = {})
|
|
183
|
+
delete("/users/#{id}", options)
|
|
184
|
+
end
|
|
185
|
+
|
|
145
186
|
# Suspend User
|
|
146
187
|
#
|
|
147
188
|
# @params id [string] User ID
|
|
@@ -151,7 +192,7 @@ module Oktakit
|
|
|
151
192
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
152
193
|
# @param options [Hash] Optional. Body params for request.
|
|
153
194
|
# @return [Hash<Sawyer::Resource>] Returns an empty object.
|
|
154
|
-
# @see
|
|
195
|
+
# @see https://developer.okta.com/docs/api/resources/users#suspend-user
|
|
155
196
|
# @example
|
|
156
197
|
# Oktakit.suspend_user('id')
|
|
157
198
|
def suspend_user(id, options = {})
|
|
@@ -167,7 +208,7 @@ module Oktakit
|
|
|
167
208
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
168
209
|
# @param options [Hash] Optional. Body params for request.
|
|
169
210
|
# @return [Hash<Sawyer::Resource>] Returns an empty object. Returns an empty object.
|
|
170
|
-
# @see
|
|
211
|
+
# @see https://developer.okta.com/docs/api/resources/users#unsuspend-user
|
|
171
212
|
# @example
|
|
172
213
|
# Oktakit.unsuspend_user('id')
|
|
173
214
|
def unsuspend_user(id, options = {})
|
|
@@ -183,7 +224,7 @@ module Oktakit
|
|
|
183
224
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
184
225
|
# @param options [Hash] Optional. Body params for request.
|
|
185
226
|
# @return [Hash<Sawyer::Resource>] Returns an empty object
|
|
186
|
-
# @see http://developer.okta.com/docs/api/resources/users
|
|
227
|
+
# @see http://developer.okta.com/docs/api/resources/users#unlock-user
|
|
187
228
|
# @example
|
|
188
229
|
# Oktakit.unlock_user('id')
|
|
189
230
|
def unlock_user(id, options = {})
|
|
@@ -199,7 +240,7 @@ module Oktakit
|
|
|
199
240
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
200
241
|
# @param options [Hash] Optional. Body params for request.
|
|
201
242
|
# @return [Hash<Sawyer::Resource>] Returns an empty object by default. If sendEmail is false a password reset link
|
|
202
|
-
# @see
|
|
243
|
+
# @see https://developer.okta.com/docs/api/resources/users#reset-password
|
|
203
244
|
# @example
|
|
204
245
|
# Oktakit.reset_password('id')
|
|
205
246
|
def reset_password(id, options = {})
|
|
@@ -215,7 +256,7 @@ module Oktakit
|
|
|
215
256
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
216
257
|
# @param options [Hash] Optional. Body params for request.
|
|
217
258
|
# @return [Hash<Sawyer::Resource>] Returns the user by default. If tempPassword is true, a temporary password.
|
|
218
|
-
# @see
|
|
259
|
+
# @see https://developer.okta.com/docs/api/resources/users#expire-password
|
|
219
260
|
# @example
|
|
220
261
|
# Oktakit.expire_password('id')
|
|
221
262
|
def expire_password(id, options = {})
|
|
@@ -231,7 +272,7 @@ module Oktakit
|
|
|
231
272
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
232
273
|
# @param options [Hash] Optional. Body params for request.
|
|
233
274
|
# @return [Hash<Sawyer::Resource>] Returns an empty object by default.
|
|
234
|
-
# @see
|
|
275
|
+
# @see https://developer.okta.com/docs/api/resources/users#reset-factors
|
|
235
276
|
# @example
|
|
236
277
|
# Oktakit.reset_factors('id')
|
|
237
278
|
def reset_factors(id, options = {})
|
|
@@ -247,7 +288,7 @@ module Oktakit
|
|
|
247
288
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
248
289
|
# @param options [Hash] Optional. Body params for request.
|
|
249
290
|
# @return [Hash<Sawyer::Resource>] Returns an empty object by default. If sendEmail is false a password reset link
|
|
250
|
-
# @see
|
|
291
|
+
# @see https://developer.okta.com/docs/api/resources/users#forgot-password
|
|
251
292
|
# @example
|
|
252
293
|
# Oktakit.forgot_password('id')
|
|
253
294
|
def forgot_password(id, options = {})
|
|
@@ -263,7 +304,7 @@ module Oktakit
|
|
|
263
304
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
264
305
|
# @param options [Hash] Optional. Body params for request.
|
|
265
306
|
# @return [Hash<Sawyer::Resource>] Credentials of the user
|
|
266
|
-
# @see
|
|
307
|
+
# @see https://developer.okta.com/docs/api/resources/users#change-password
|
|
267
308
|
# @example
|
|
268
309
|
# Oktakit.change_password('id')
|
|
269
310
|
def change_password(id, options = {})
|
|
@@ -279,12 +320,27 @@ module Oktakit
|
|
|
279
320
|
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
280
321
|
# @param options [Hash] Optional. Body params for request.
|
|
281
322
|
# @return [Hash<Sawyer::Resource>] Credentials of the user
|
|
282
|
-
# @see
|
|
323
|
+
# @see https://developer.okta.com/docs/api/resources/users#change-recovery-question
|
|
283
324
|
# @example
|
|
284
325
|
# Oktakit.change_recovery_question('id')
|
|
285
326
|
def change_recovery_question(id, options = {})
|
|
286
327
|
post("/users/#{id}/credentials/change_recovery_question", options)
|
|
287
328
|
end
|
|
329
|
+
|
|
330
|
+
# Clear user sessions
|
|
331
|
+
#
|
|
332
|
+
# @params id [string] User ID
|
|
333
|
+
# @param options[:query] [Hash] Optional. Query params for request
|
|
334
|
+
# @param options[:headers] [Hash] Optional. Header params for the request.
|
|
335
|
+
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
|
|
336
|
+
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
|
|
337
|
+
# @param options [Hash] Optional. Body params for the request.
|
|
338
|
+
# @return 204 'No Content'
|
|
339
|
+
# @see https://developer.okta.com/docs/api/resources/users#user-sessions
|
|
340
|
+
# Oktakit.clear_user_sessions('id')
|
|
341
|
+
def clear_user_sessions(id, options = {})
|
|
342
|
+
delete("/users/#{id}/sessions", options)
|
|
343
|
+
end
|
|
288
344
|
end
|
|
289
345
|
end
|
|
290
346
|
end
|
data/lib/oktakit/client.rb
CHANGED
|
@@ -5,6 +5,7 @@ require 'oktakit/client/apps'
|
|
|
5
5
|
require 'oktakit/client/events'
|
|
6
6
|
require 'oktakit/client/factors'
|
|
7
7
|
require 'oktakit/client/groups'
|
|
8
|
+
require 'oktakit/client/group_rules'
|
|
8
9
|
require 'oktakit/client/identity_providers'
|
|
9
10
|
require 'oktakit/client/schemas'
|
|
10
11
|
require 'oktakit/client/templates'
|
|
@@ -17,6 +18,7 @@ module Oktakit
|
|
|
17
18
|
include Events
|
|
18
19
|
include Factors
|
|
19
20
|
include Groups
|
|
21
|
+
include GroupRules
|
|
20
22
|
include IdentityProviders
|
|
21
23
|
include Schemas
|
|
22
24
|
include Templates
|
|
@@ -27,13 +29,27 @@ module Oktakit
|
|
|
27
29
|
|
|
28
30
|
# Default Faraday middleware stack
|
|
29
31
|
MIDDLEWARE = RACK_BUILDER_CLASS.new do |builder|
|
|
30
|
-
builder.use
|
|
31
|
-
builder.adapter
|
|
32
|
+
builder.use(Oktakit::Response::RaiseError)
|
|
33
|
+
builder.adapter(Faraday.default_adapter)
|
|
32
34
|
end
|
|
33
35
|
|
|
34
|
-
def initialize(token
|
|
36
|
+
def initialize(token: nil, access_token: nil, organization: nil, api_endpoint: nil)
|
|
37
|
+
if organization.nil? && api_endpoint.nil?
|
|
38
|
+
raise ArgumentError, "Please provide either the organization or the api_endpoint argument"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
if (token.nil? && access_token.nil?) || (token && access_token)
|
|
42
|
+
raise ArgumentError, "Please provide either the token or the access_token argument"
|
|
43
|
+
end
|
|
44
|
+
|
|
35
45
|
@token = token
|
|
46
|
+
@access_token = access_token
|
|
36
47
|
@organization = organization
|
|
48
|
+
@api_endpoint = api_endpoint
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def api_endpoint
|
|
52
|
+
@api_endpoint || "https://#{@organization.downcase}.okta.com/api/v1"
|
|
37
53
|
end
|
|
38
54
|
|
|
39
55
|
# Make a HTTP GET request
|
|
@@ -48,18 +64,25 @@ module Oktakit
|
|
|
48
64
|
# @return [Sawyer::Resource]
|
|
49
65
|
def get(url, options = {})
|
|
50
66
|
should_paginate = options.delete(:paginate)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
request_options = {
|
|
68
|
+
query: options.delete(:query),
|
|
69
|
+
headers: options.delete(:headers),
|
|
70
|
+
accept: options.delete(:accept),
|
|
71
|
+
content_type: options.delete(:content_type),
|
|
72
|
+
paginate: should_paginate,
|
|
73
|
+
data: options,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
resp, status, next_page = request(:get, url, **request_options)
|
|
77
|
+
|
|
78
|
+
# If request succeeded and we should paginate, then automatically traverse all next_pages
|
|
79
|
+
if status == 200 && should_paginate
|
|
59
80
|
all_objs = [resp]
|
|
60
|
-
while next_page
|
|
61
|
-
next_page =
|
|
62
|
-
|
|
81
|
+
while next_page
|
|
82
|
+
resp, status, next_page = request(:get, next_page, **request_options)
|
|
83
|
+
break unless status == 200 # Return early if page request fails
|
|
84
|
+
|
|
85
|
+
all_objs << resp
|
|
63
86
|
end
|
|
64
87
|
resp = all_objs.flatten
|
|
65
88
|
end
|
|
@@ -77,9 +100,9 @@ module Oktakit
|
|
|
77
100
|
# @param options [Hash] Optional. Body params for request.
|
|
78
101
|
# @return [Sawyer::Resource]
|
|
79
102
|
def post(url, options = {})
|
|
80
|
-
request
|
|
103
|
+
request(:post, url, query: options.delete(:query), headers: options.delete(:headers),
|
|
81
104
|
accept: options.delete(:accept), content_type: options.delete(:content_type),
|
|
82
|
-
data: options
|
|
105
|
+
data: options)
|
|
83
106
|
end
|
|
84
107
|
|
|
85
108
|
# Make a HTTP PUT request
|
|
@@ -92,9 +115,9 @@ module Oktakit
|
|
|
92
115
|
# @param options [Hash] Optional. Body params for request.
|
|
93
116
|
# @return [Sawyer::Resource]
|
|
94
117
|
def put(url, options = {})
|
|
95
|
-
request
|
|
118
|
+
request(:put, url, query: options.delete(:query), headers: options.delete(:headers),
|
|
96
119
|
accept: options.delete(:accept), content_type: options.delete(:content_type),
|
|
97
|
-
data: options
|
|
120
|
+
data: options)
|
|
98
121
|
end
|
|
99
122
|
|
|
100
123
|
# Make a HTTP PATCH request
|
|
@@ -107,9 +130,9 @@ module Oktakit
|
|
|
107
130
|
# @param options [Hash] Optional. Body params for request.
|
|
108
131
|
# @return [Sawyer::Resource]
|
|
109
132
|
def patch(url, options = {})
|
|
110
|
-
request
|
|
133
|
+
request(:patch, url, query: options.delete(:query), headers: options.delete(:headers),
|
|
111
134
|
accept: options.delete(:accept), content_type: options.delete(:content_type),
|
|
112
|
-
data: options
|
|
135
|
+
data: options)
|
|
113
136
|
end
|
|
114
137
|
|
|
115
138
|
# Make a HTTP DELETE request
|
|
@@ -122,9 +145,9 @@ module Oktakit
|
|
|
122
145
|
# @param options [Hash] Optional. Body params for request.
|
|
123
146
|
# @return [Sawyer::Resource]
|
|
124
147
|
def delete(url, options = {})
|
|
125
|
-
request
|
|
148
|
+
request(:delete, url, query: options.delete(:query), headers: options.delete(:headers),
|
|
126
149
|
accept: options.delete(:accept), content_type: options.delete(:content_type),
|
|
127
|
-
data: options
|
|
150
|
+
data: options)
|
|
128
151
|
end
|
|
129
152
|
|
|
130
153
|
# Make a HTTP HEAD request
|
|
@@ -137,9 +160,9 @@ module Oktakit
|
|
|
137
160
|
# @param options [Hash] Optional. Body params for request.
|
|
138
161
|
# @return [Sawyer::Resource]
|
|
139
162
|
def head(url, options = {})
|
|
140
|
-
request
|
|
163
|
+
request(:head, url, query: options.delete(:query), headers: options.delete(:headers),
|
|
141
164
|
accept: options.delete(:accept), content_type: options.delete(:content_type),
|
|
142
|
-
data: options
|
|
165
|
+
data: options)
|
|
143
166
|
end
|
|
144
167
|
|
|
145
168
|
attr_reader :last_response
|
|
@@ -153,20 +176,21 @@ module Oktakit
|
|
|
153
176
|
options[:headers][:accept] = accept if accept
|
|
154
177
|
options[:headers][:content_type] = content_type if content_type
|
|
155
178
|
|
|
156
|
-
uri = URI::
|
|
179
|
+
uri = URI::DEFAULT_PARSER.escape("/api/v1" + path.to_s)
|
|
157
180
|
@last_response = resp = sawyer_agent.call(method, uri, data, options)
|
|
158
181
|
|
|
159
182
|
response = [resp.data, resp.status]
|
|
160
|
-
response << resp.rels[:next] if paginate
|
|
183
|
+
response << absolute_to_relative_url(resp.rels[:next]) if paginate
|
|
161
184
|
response
|
|
162
185
|
end
|
|
163
186
|
|
|
164
187
|
def sawyer_agent
|
|
165
|
-
@
|
|
188
|
+
@sawyer_agent ||= Sawyer::Agent.new(api_endpoint, sawyer_options) do |http|
|
|
166
189
|
http.headers[:accept] = 'application/json'
|
|
167
190
|
http.headers[:content_type] = 'application/json'
|
|
168
191
|
http.headers[:user_agent] = "Oktakit v#{Oktakit::VERSION}"
|
|
169
|
-
http.authorization
|
|
192
|
+
http.authorization('SSWS ', @token) if @token
|
|
193
|
+
http.authorization(:Bearer, @access_token) if @access_token
|
|
170
194
|
end
|
|
171
195
|
end
|
|
172
196
|
|
|
@@ -177,8 +201,10 @@ module Oktakit
|
|
|
177
201
|
}
|
|
178
202
|
end
|
|
179
203
|
|
|
180
|
-
def
|
|
181
|
-
|
|
204
|
+
def absolute_to_relative_url(next_ref)
|
|
205
|
+
return unless next_ref
|
|
206
|
+
|
|
207
|
+
next_ref.href.sub(api_endpoint, '')
|
|
182
208
|
end
|
|
183
209
|
end
|
|
184
210
|
end
|
data/lib/oktakit/error.rb
CHANGED
|
@@ -8,7 +8,7 @@ module Oktakit
|
|
|
8
8
|
# @return [Oktakit::Error]
|
|
9
9
|
def self.from_response(response)
|
|
10
10
|
status = response[:status].to_i
|
|
11
|
-
if klass = error(status)
|
|
11
|
+
if (klass = error(status))
|
|
12
12
|
klass.new(response)
|
|
13
13
|
end
|
|
14
14
|
end
|
|
@@ -41,19 +41,19 @@ module Oktakit
|
|
|
41
41
|
# Array of validation errors
|
|
42
42
|
# @return [Array<Hash>] Error info
|
|
43
43
|
def errors
|
|
44
|
-
if data
|
|
44
|
+
if data&.is_a?(Hash)
|
|
45
45
|
data[:errors] || []
|
|
46
46
|
else
|
|
47
47
|
[]
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
private
|
|
52
|
-
|
|
53
51
|
def data
|
|
54
52
|
@data ||= parse_data
|
|
55
53
|
end
|
|
56
54
|
|
|
55
|
+
private
|
|
56
|
+
|
|
57
57
|
def parse_data
|
|
58
58
|
body = @response[:body]
|
|
59
59
|
return if body.empty?
|
|
@@ -88,8 +88,8 @@ module Oktakit
|
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
def redact_url(url_string)
|
|
91
|
-
%w
|
|
92
|
-
url_string.gsub!(/#{token}=\S+/, "#{token}=(redacted)") if url_string.include?
|
|
91
|
+
%w[client_secret access_token].each do |token|
|
|
92
|
+
url_string.gsub!(/#{token}=\S+/, "#{token}=(redacted)") if url_string.include?(token)
|
|
93
93
|
end
|
|
94
94
|
url_string
|
|
95
95
|
end
|
|
@@ -7,10 +7,8 @@ module Oktakit
|
|
|
7
7
|
# This class raises an Oktakit-flavored exception based
|
|
8
8
|
# HTTP status codes returned by the API
|
|
9
9
|
class RaiseError < Faraday::Response::Middleware
|
|
10
|
-
private
|
|
11
|
-
|
|
12
10
|
def on_complete(response)
|
|
13
|
-
if error = Oktakit::Error.from_response(response)
|
|
11
|
+
if (error = Oktakit::Error.from_response(response))
|
|
14
12
|
raise error
|
|
15
13
|
end
|
|
16
14
|
end
|
data/lib/oktakit/version.rb
CHANGED
data/lib/oktakit.rb
CHANGED
data/oktakit.gemspec
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
3
|
require 'oktakit/version'
|
|
5
4
|
|
|
@@ -10,16 +9,16 @@ Gem::Specification.new do |spec|
|
|
|
10
9
|
spec.email = ['graeme.johnson@shopify.com', 'julian@shopify.com']
|
|
11
10
|
|
|
12
11
|
spec.summary = 'Ruby toolkit for working with the Okta API'
|
|
13
|
-
spec.homepage = 'https://github.com/
|
|
12
|
+
spec.homepage = 'https://github.com/Shopify/oktakit'
|
|
14
13
|
spec.license = 'MIT'
|
|
15
14
|
|
|
16
|
-
spec.files =
|
|
15
|
+
spec.files = %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
17
16
|
spec.bindir = 'exe'
|
|
18
17
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
18
|
spec.require_paths = ['lib']
|
|
20
19
|
|
|
21
|
-
spec.required_ruby_version = '>= 2.
|
|
20
|
+
spec.required_ruby_version = '>= 2.6'
|
|
22
21
|
|
|
23
|
-
spec.add_dependency
|
|
24
|
-
spec.add_development_dependency
|
|
22
|
+
spec.add_dependency('sawyer', '~> 0.8.1')
|
|
23
|
+
spec.add_development_dependency('bundler')
|
|
25
24
|
end
|
metadata
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: oktakit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Graeme Johnson
|
|
8
8
|
- Julian Nadeau
|
|
9
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: sawyer
|
|
@@ -17,14 +17,14 @@ dependencies:
|
|
|
17
17
|
requirements:
|
|
18
18
|
- - "~>"
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: 0.
|
|
20
|
+
version: 0.8.1
|
|
21
21
|
type: :runtime
|
|
22
22
|
prerelease: false
|
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
24
|
requirements:
|
|
25
25
|
- - "~>"
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
|
-
version: 0.
|
|
27
|
+
version: 0.8.1
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
29
29
|
name: bundler
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -39,7 +39,7 @@ dependencies:
|
|
|
39
39
|
- - ">="
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
41
|
version: '0'
|
|
42
|
-
description:
|
|
42
|
+
description:
|
|
43
43
|
email:
|
|
44
44
|
- graeme.johnson@shopify.com
|
|
45
45
|
- julian@shopify.com
|
|
@@ -47,11 +47,17 @@ executables: []
|
|
|
47
47
|
extensions: []
|
|
48
48
|
extra_rdoc_files: []
|
|
49
49
|
files:
|
|
50
|
+
- ".github/probots.yml"
|
|
51
|
+
- ".github/workflows/ci.yml"
|
|
50
52
|
- ".gitignore"
|
|
51
53
|
- ".rspec"
|
|
52
54
|
- ".rubocop.yml"
|
|
55
|
+
- ".ruby-version"
|
|
53
56
|
- ".travis.yml"
|
|
57
|
+
- CHANGELOG.md
|
|
58
|
+
- CODE_OF_CONDUCT.md
|
|
54
59
|
- Gemfile
|
|
60
|
+
- Gemfile.lock
|
|
55
61
|
- LICENSE.txt
|
|
56
62
|
- README.md
|
|
57
63
|
- Rakefile
|
|
@@ -64,6 +70,7 @@ files:
|
|
|
64
70
|
- lib/oktakit/client/apps.rb
|
|
65
71
|
- lib/oktakit/client/events.rb
|
|
66
72
|
- lib/oktakit/client/factors.rb
|
|
73
|
+
- lib/oktakit/client/group_rules.rb
|
|
67
74
|
- lib/oktakit/client/groups.rb
|
|
68
75
|
- lib/oktakit/client/identity_providers.rb
|
|
69
76
|
- lib/oktakit/client/schemas.rb
|
|
@@ -73,11 +80,11 @@ files:
|
|
|
73
80
|
- lib/oktakit/response/raise_error.rb
|
|
74
81
|
- lib/oktakit/version.rb
|
|
75
82
|
- oktakit.gemspec
|
|
76
|
-
homepage: https://github.com/
|
|
83
|
+
homepage: https://github.com/Shopify/oktakit
|
|
77
84
|
licenses:
|
|
78
85
|
- MIT
|
|
79
86
|
metadata: {}
|
|
80
|
-
post_install_message:
|
|
87
|
+
post_install_message:
|
|
81
88
|
rdoc_options: []
|
|
82
89
|
require_paths:
|
|
83
90
|
- lib
|
|
@@ -85,16 +92,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
85
92
|
requirements:
|
|
86
93
|
- - ">="
|
|
87
94
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '2.
|
|
95
|
+
version: '2.6'
|
|
89
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
97
|
requirements:
|
|
91
98
|
- - ">="
|
|
92
99
|
- !ruby/object:Gem::Version
|
|
93
100
|
version: '0'
|
|
94
101
|
requirements: []
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
signing_key:
|
|
102
|
+
rubygems_version: 3.2.20
|
|
103
|
+
signing_key:
|
|
98
104
|
specification_version: 4
|
|
99
105
|
summary: Ruby toolkit for working with the Okta API
|
|
100
106
|
test_files: []
|