kinde_sdk 1.2.1 → 1.2.2
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 +4 -4
- data/Gemfile.lock +128 -0
- data/README.md +12 -434
- data/kinde_api/README.md +98 -27
- data/kinde_api/docs/APIsApi.md +356 -0
- data/kinde_api/docs/AddAPIsRequest.md +20 -0
- data/kinde_api/docs/Api.md +28 -0
- data/kinde_api/docs/ApiApplicationsInner.md +24 -0
- data/kinde_api/docs/Apis.md +24 -0
- data/kinde_api/docs/Applications.md +22 -0
- data/kinde_api/docs/ApplicationsApi.md +368 -0
- data/kinde_api/docs/BusinessApi.md +183 -0
- data/kinde_api/docs/CallbacksApi.md +385 -25
- data/kinde_api/docs/CreateApplicationRequest.md +20 -0
- data/kinde_api/docs/CreateApplicationResponse.md +22 -0
- data/kinde_api/docs/CreateApplicationResponseApplication.md +22 -0
- data/kinde_api/docs/CreateFeatureFlagRequest.md +28 -0
- data/kinde_api/docs/CreateOrganizationRequest.md +3 -1
- data/kinde_api/docs/CreateOrganizationUserPermissionRequest.md +18 -0
- data/kinde_api/docs/EnvironmentsApi.md +23 -23
- data/kinde_api/docs/FeatureFlagsApi.md +19 -29
- data/kinde_api/docs/GetApplicationResponse.md +22 -0
- data/kinde_api/docs/GetApplicationResponseApplication.md +26 -0
- data/kinde_api/docs/GetApplicationsResponse.md +2 -2
- data/kinde_api/docs/{GetOrganizationsUsersResponse.md → GetOrganizationUsersResponse.md} +2 -2
- data/kinde_api/docs/GetOrganizationsUserPermissionsResponse.md +22 -0
- data/kinde_api/docs/GetPermissionsResponse.md +24 -0
- data/kinde_api/docs/GetRolesResponse.md +24 -0
- data/kinde_api/docs/GetSubscriberResponse.md +22 -0
- data/kinde_api/docs/GetSubscribersResponse.md +24 -0
- data/kinde_api/docs/IndustriesApi.md +81 -0
- data/kinde_api/docs/LogoutRedirectUrls.md +18 -0
- data/kinde_api/docs/OAuthApi.md +153 -4
- data/kinde_api/docs/Organization.md +3 -1
- data/kinde_api/docs/OrganizationUserPermission.md +26 -0
- data/kinde_api/docs/OrganizationUserPermissionRolesInner.md +20 -0
- data/kinde_api/docs/OrganizationUserRolePermissions.md +22 -0
- data/kinde_api/docs/OrganizationUserRolePermissionsPermissions.md +18 -0
- data/kinde_api/docs/OrganizationsApi.md +328 -32
- data/kinde_api/docs/PermissionsApi.md +84 -14
- data/kinde_api/docs/ReplaceLogoutRedirectURLsRequest.md +18 -0
- data/kinde_api/docs/ReplaceRedirectCallbackURLsRequest.md +18 -0
- data/kinde_api/docs/Role.md +24 -0
- data/kinde_api/docs/Roles.md +2 -0
- data/kinde_api/docs/RolesApi.md +309 -17
- data/kinde_api/docs/RolesPermissionResponseInner.md +24 -0
- data/kinde_api/docs/Subscriber.md +24 -0
- data/kinde_api/docs/SubscribersApi.md +12 -14
- data/kinde_api/docs/SubscribersSubscriber.md +26 -0
- data/kinde_api/docs/TimezonesApi.md +81 -0
- data/kinde_api/docs/TokenErrorResponse.md +20 -0
- data/kinde_api/docs/TokenIntrospect.md +26 -0
- data/kinde_api/docs/UpdateAPIApplicationsRequest.md +18 -0
- data/kinde_api/docs/UpdateAPIApplicationsRequestApplicationsInner.md +20 -0
- data/kinde_api/docs/UpdateApplicationRequest.md +24 -0
- data/kinde_api/docs/UpdateEnvironementFeatureFlagOverrideRequest.md +18 -0
- data/kinde_api/docs/UpdateOrganizationRequest.md +3 -1
- data/kinde_api/docs/UpdateOrganizationUsersRequest.md +1 -1
- data/kinde_api/docs/UpdateRolePermissionsRequest.md +18 -0
- data/kinde_api/docs/UpdateRolePermissionsRequestPermissionsInner.md +20 -0
- data/kinde_api/docs/UpdateRolePermissionsResponse.md +24 -0
- data/kinde_api/docs/UpdateRolesRequest.md +24 -0
- data/kinde_api/docs/UpdateUserResponse.md +30 -0
- data/kinde_api/docs/User.md +7 -7
- data/kinde_api/docs/UserIdentitiesInner.md +20 -0
- data/kinde_api/docs/UsersApi.md +93 -15
- data/kinde_api/docs/UsersResponse.md +1 -1
- data/kinde_api/docs/UsersResponseUsersInner.md +42 -0
- data/kinde_api/lib/kinde_api/api/apis_api.rb +347 -0
- data/kinde_api/lib/kinde_api/api/applications_api.rb +352 -0
- data/kinde_api/lib/kinde_api/api/business_api.rb +210 -0
- data/kinde_api/lib/kinde_api/api/callbacks_api.rb +394 -31
- data/kinde_api/lib/kinde_api/api/environments_api.rb +22 -18
- data/kinde_api/lib/kinde_api/api/feature_flags_api.rb +20 -61
- data/kinde_api/lib/kinde_api/api/industries_api.rb +85 -0
- data/kinde_api/lib/kinde_api/api/o_auth_api.rb +141 -2
- data/kinde_api/lib/kinde_api/api/organizations_api.rb +318 -25
- data/kinde_api/lib/kinde_api/api/permissions_api.rb +75 -12
- data/kinde_api/lib/kinde_api/api/roles_api.rb +297 -15
- data/kinde_api/lib/kinde_api/api/subscribers_api.rb +8 -11
- data/kinde_api/lib/kinde_api/api/timezones_api.rb +85 -0
- data/kinde_api/lib/kinde_api/api/users_api.rb +87 -11
- data/kinde_api/lib/kinde_api/api_client.rb +14 -7
- data/kinde_api/lib/kinde_api/configuration.rb +81 -5
- data/kinde_api/lib/kinde_api/models/add_apis_request.rb +238 -0
- data/kinde_api/lib/kinde_api/models/add_organization_users_request.rb +2 -0
- data/kinde_api/lib/kinde_api/models/add_organization_users_request_users_inner.rb +2 -0
- data/kinde_api/lib/kinde_api/models/add_organization_users_response.rb +2 -0
- data/kinde_api/lib/kinde_api/models/api.rb +271 -0
- data/kinde_api/lib/kinde_api/models/api_applications_inner.rb +246 -0
- data/kinde_api/lib/kinde_api/models/api_result.rb +2 -0
- data/kinde_api/lib/kinde_api/models/apis.rb +250 -0
- data/kinde_api/lib/kinde_api/models/applications.rb +237 -0
- data/kinde_api/lib/kinde_api/models/connected_apps_access_token.rb +2 -0
- data/kinde_api/lib/kinde_api/models/connected_apps_auth_url.rb +2 -0
- data/kinde_api/lib/kinde_api/models/create_application_request.rb +264 -0
- data/kinde_api/lib/kinde_api/models/create_application_response.rb +239 -0
- data/kinde_api/lib/kinde_api/models/create_application_response_application.rb +240 -0
- data/kinde_api/lib/kinde_api/models/create_feature_flag_request.rb +336 -0
- data/kinde_api/lib/kinde_api/models/create_organization_request.rb +16 -4
- data/kinde_api/lib/kinde_api/models/create_organization_response.rb +2 -0
- data/kinde_api/lib/kinde_api/models/create_organization_response_organization.rb +2 -0
- data/kinde_api/lib/kinde_api/models/{application.rb → create_organization_user_permission_request.rb} +13 -19
- data/kinde_api/lib/kinde_api/models/create_organization_user_role_request.rb +2 -0
- data/kinde_api/lib/kinde_api/models/create_permission_request.rb +2 -0
- data/kinde_api/lib/kinde_api/models/create_role_request.rb +2 -0
- data/kinde_api/lib/kinde_api/models/create_subscriber_success_response.rb +2 -0
- data/kinde_api/lib/kinde_api/models/create_subscriber_success_response_subscriber.rb +2 -0
- data/kinde_api/lib/kinde_api/models/create_user_request.rb +2 -0
- data/kinde_api/lib/kinde_api/models/create_user_request_identities_inner.rb +2 -0
- data/kinde_api/lib/kinde_api/models/create_user_request_identities_inner_details.rb +2 -0
- data/kinde_api/lib/kinde_api/models/create_user_request_profile.rb +2 -0
- data/kinde_api/lib/kinde_api/models/create_user_response.rb +2 -0
- data/kinde_api/lib/kinde_api/models/error.rb +2 -0
- data/kinde_api/lib/kinde_api/models/error_response.rb +2 -0
- data/kinde_api/lib/kinde_api/models/get_application_response.rb +239 -0
- data/kinde_api/lib/kinde_api/models/get_application_response_application.rb +260 -0
- data/kinde_api/lib/kinde_api/models/get_applications_response.rb +10 -8
- data/kinde_api/lib/kinde_api/models/get_environment_feature_flags_response.rb +2 -0
- data/kinde_api/lib/kinde_api/models/get_organization_feature_flags_response.rb +2 -0
- data/kinde_api/lib/kinde_api/models/get_organization_feature_flags_response_feature_flags_value.rb +2 -0
- data/kinde_api/lib/kinde_api/models/{get_organizations_users_response.rb → get_organization_users_response.rb} +5 -3
- data/kinde_api/lib/kinde_api/models/get_organizations_response.rb +2 -0
- data/kinde_api/lib/kinde_api/models/get_organizations_user_permissions_response.rb +241 -0
- data/kinde_api/lib/kinde_api/models/get_organizations_user_roles_response.rb +2 -0
- data/kinde_api/lib/kinde_api/models/get_permissions_response.rb +251 -0
- data/kinde_api/lib/kinde_api/models/get_redirect_callback_urls_response.rb +2 -0
- data/kinde_api/lib/kinde_api/models/get_roles_response.rb +251 -0
- data/kinde_api/lib/kinde_api/models/get_subscriber_response.rb +241 -0
- data/kinde_api/lib/kinde_api/models/get_subscribers_response.rb +251 -0
- data/kinde_api/lib/kinde_api/models/logout_redirect_urls.rb +222 -0
- data/kinde_api/lib/kinde_api/models/organization.rb +15 -4
- data/kinde_api/lib/kinde_api/models/organization_user.rb +2 -0
- data/kinde_api/lib/kinde_api/models/organization_user_permission.rb +257 -0
- data/kinde_api/lib/kinde_api/models/organization_user_permission_roles_inner.rb +228 -0
- data/kinde_api/lib/kinde_api/models/organization_user_role.rb +2 -0
- data/kinde_api/lib/kinde_api/models/organization_user_role_permissions.rb +237 -0
- data/kinde_api/lib/kinde_api/models/organization_user_role_permissions_permissions.rb +219 -0
- data/kinde_api/lib/kinde_api/models/permissions.rb +2 -0
- data/kinde_api/lib/kinde_api/models/redirect_callback_urls.rb +2 -0
- data/kinde_api/lib/kinde_api/models/replace_logout_redirect_urls_request.rb +222 -0
- data/kinde_api/lib/kinde_api/models/replace_redirect_callback_urls_request.rb +222 -0
- data/kinde_api/lib/kinde_api/models/role.rb +246 -0
- data/kinde_api/lib/kinde_api/models/roles.rb +13 -1
- data/kinde_api/lib/kinde_api/models/roles_permission_response_inner.rb +246 -0
- data/kinde_api/lib/kinde_api/models/subscriber.rb +246 -0
- data/kinde_api/lib/kinde_api/models/subscribers_subscriber.rb +255 -0
- data/kinde_api/lib/kinde_api/models/success_response.rb +2 -0
- data/kinde_api/lib/kinde_api/models/token_error_response.rb +230 -0
- data/kinde_api/lib/kinde_api/models/token_introspect.rb +262 -0
- data/kinde_api/lib/kinde_api/models/update_api_applications_request.rb +226 -0
- data/kinde_api/lib/kinde_api/models/update_api_applications_request_applications_inner.rb +235 -0
- data/kinde_api/lib/kinde_api/models/update_application_request.rb +254 -0
- data/kinde_api/lib/kinde_api/models/update_environement_feature_flag_override_request.rb +225 -0
- data/kinde_api/lib/kinde_api/models/update_organization_request.rb +16 -4
- data/kinde_api/lib/kinde_api/models/update_organization_users_request.rb +3 -1
- data/kinde_api/lib/kinde_api/models/update_organization_users_request_users_inner.rb +2 -0
- data/kinde_api/lib/kinde_api/models/update_organization_users_response.rb +2 -0
- data/kinde_api/lib/kinde_api/models/update_role_permissions_request.rb +222 -0
- data/kinde_api/lib/kinde_api/models/update_role_permissions_request_permissions_inner.rb +230 -0
- data/kinde_api/lib/kinde_api/models/update_role_permissions_response.rb +250 -0
- data/kinde_api/lib/kinde_api/models/update_roles_request.rb +260 -0
- data/kinde_api/lib/kinde_api/models/update_user_request.rb +2 -0
- data/kinde_api/lib/kinde_api/models/update_user_response.rb +280 -0
- data/kinde_api/lib/kinde_api/models/user.rb +37 -32
- data/kinde_api/lib/kinde_api/models/user_identities_inner.rb +228 -0
- data/kinde_api/lib/kinde_api/models/user_identity.rb +2 -0
- data/kinde_api/lib/kinde_api/models/user_identity_result.rb +2 -0
- data/kinde_api/lib/kinde_api/models/user_profile.rb +2 -0
- data/kinde_api/lib/kinde_api/models/user_profile_v2.rb +2 -0
- data/kinde_api/lib/kinde_api/models/users_response.rb +3 -1
- data/kinde_api/lib/kinde_api/models/users_response_users_inner.rb +348 -0
- data/kinde_api/lib/kinde_api.rb +47 -2
- data/kinde_api/spec/api/apis_api_spec.rb +95 -0
- data/kinde_api/spec/api/applications_api_spec.rb +98 -0
- data/kinde_api/spec/api/business_api_spec.rb +75 -0
- data/kinde_api/spec/api/callbacks_api_spec.rb +69 -5
- data/kinde_api/spec/api/environments_api_spec.rb +5 -5
- data/kinde_api/spec/api/feature_flags_api_spec.rb +4 -9
- data/kinde_api/spec/api/industries_api_spec.rb +48 -0
- data/kinde_api/spec/api/o_auth_api_spec.rb +28 -1
- data/kinde_api/spec/api/organizations_api_spec.rb +63 -8
- data/kinde_api/spec/api/permissions_api_spec.rb +16 -4
- data/kinde_api/spec/api/roles_api_spec.rb +57 -4
- data/kinde_api/spec/api/subscribers_api_spec.rb +3 -4
- data/kinde_api/spec/api/timezones_api_spec.rb +48 -0
- data/kinde_api/spec/api/users_api_spec.rb +17 -2
- data/kinde_api/spec/api_client_spec.rb +13 -2
- data/kinde_api/spec/models/{application_spec.rb → add_apis_request_spec.rb} +8 -8
- data/kinde_api/spec/models/api_applications_inner_spec.rb +52 -0
- data/kinde_api/spec/models/api_spec.rb +64 -0
- data/kinde_api/spec/models/apis_spec.rb +52 -0
- data/kinde_api/spec/models/applications_spec.rb +46 -0
- data/kinde_api/spec/models/create_application_request_spec.rb +44 -0
- data/kinde_api/spec/models/create_application_response_application_spec.rb +46 -0
- data/kinde_api/spec/models/create_application_response_spec.rb +46 -0
- data/kinde_api/spec/models/create_feature_flag_request_spec.rb +72 -0
- data/kinde_api/spec/models/create_organization_request_spec.rb +6 -0
- data/kinde_api/spec/models/create_organization_user_permission_request_spec.rb +34 -0
- data/kinde_api/spec/models/get_application_response_application_spec.rb +58 -0
- data/kinde_api/spec/models/get_application_response_spec.rb +46 -0
- data/kinde_api/spec/models/get_applications_response_spec.rb +1 -1
- data/kinde_api/spec/models/{get_organizations_users_response_spec.rb → get_organization_users_response_spec.rb} +6 -6
- data/kinde_api/spec/models/get_organizations_user_permissions_response_spec.rb +46 -0
- data/kinde_api/spec/models/get_permissions_response_spec.rb +52 -0
- data/kinde_api/spec/models/get_roles_response_spec.rb +52 -0
- data/kinde_api/spec/models/get_subscriber_response_spec.rb +46 -0
- data/kinde_api/spec/models/get_subscribers_response_spec.rb +52 -0
- data/kinde_api/spec/models/logout_redirect_urls_spec.rb +34 -0
- data/kinde_api/spec/models/organization_spec.rb +6 -0
- data/kinde_api/spec/models/organization_user_permission_roles_inner_spec.rb +40 -0
- data/kinde_api/spec/models/organization_user_permission_spec.rb +58 -0
- data/kinde_api/spec/models/organization_user_role_permissions_permissions_spec.rb +34 -0
- data/kinde_api/spec/models/organization_user_role_permissions_spec.rb +46 -0
- data/kinde_api/spec/models/replace_logout_redirect_urls_request_spec.rb +34 -0
- data/kinde_api/spec/models/replace_redirect_callback_urls_request_spec.rb +34 -0
- data/kinde_api/spec/models/role_spec.rb +52 -0
- data/kinde_api/spec/models/roles_permission_response_inner_spec.rb +52 -0
- data/kinde_api/spec/models/roles_spec.rb +6 -0
- data/kinde_api/spec/models/subscriber_spec.rb +52 -0
- data/kinde_api/spec/models/subscribers_subscriber_spec.rb +58 -0
- data/kinde_api/spec/models/token_error_response_spec.rb +40 -0
- data/kinde_api/spec/models/token_introspect_spec.rb +58 -0
- data/kinde_api/spec/models/update_api_applications_request_applications_inner_spec.rb +40 -0
- data/kinde_api/spec/models/update_api_applications_request_spec.rb +34 -0
- data/kinde_api/spec/models/update_application_request_spec.rb +52 -0
- data/kinde_api/spec/models/update_environement_feature_flag_override_request_spec.rb +34 -0
- data/kinde_api/spec/models/update_organization_request_spec.rb +6 -0
- data/kinde_api/spec/models/update_role_permissions_request_permissions_inner_spec.rb +40 -0
- data/kinde_api/spec/models/update_role_permissions_request_spec.rb +34 -0
- data/kinde_api/spec/models/update_role_permissions_response_spec.rb +52 -0
- data/kinde_api/spec/models/update_roles_request_spec.rb +52 -0
- data/kinde_api/spec/models/update_user_response_spec.rb +70 -0
- data/kinde_api/spec/models/user_identities_inner_spec.rb +40 -0
- data/kinde_api/spec/models/user_spec.rb +9 -9
- data/kinde_api/spec/models/users_response_users_inner_spec.rb +106 -0
- data/kinde_sdk.gemspec +1 -1
- data/lib/kinde_sdk/version.rb +1 -1
- data/spec/kinde_sdk_spec.rb +0 -46
- metadata +193 -12
- data/kinde_api/docs/Application.md +0 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0a84ffe92552e8ab43146d5fd7445edefc924495388368adae348ae48ba6d621
|
|
4
|
+
data.tar.gz: 779838b43100f0d9e78fe54199f7e9f26b9818f6fe18904529664b7de631f6d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9469af65325f71dab96c2c901fc2ffa70258ed92f65841d5009f1dd67536d704ef917000638ff1e00eb17a3fb7edc6095fa1fecae66574d3c1837d72ba1491e4
|
|
7
|
+
data.tar.gz: a3cc75b2c027b5ff0d166f7bd54e942f7c7efa467586a175fb1f83412d3d7829d2ddb58cd4bf3eb7b1594019f85c6417bce0c3435b67c6ef4552ecf7793cbdb0
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
kinde_sdk (1.2.1)
|
|
5
|
+
faraday-follow_redirects
|
|
6
|
+
oauth2 (~> 2.0)
|
|
7
|
+
pkce_challenge
|
|
8
|
+
typhoeus (~> 1.0, >= 1.0.1)
|
|
9
|
+
|
|
10
|
+
GEM
|
|
11
|
+
remote: https://rubygems.org/
|
|
12
|
+
specs:
|
|
13
|
+
addressable (2.8.5)
|
|
14
|
+
public_suffix (>= 2.0.2, < 6.0)
|
|
15
|
+
ast (2.4.2)
|
|
16
|
+
base64 (0.1.1)
|
|
17
|
+
byebug (11.1.3)
|
|
18
|
+
coderay (1.1.3)
|
|
19
|
+
crack (0.4.5)
|
|
20
|
+
rexml
|
|
21
|
+
diff-lcs (1.5.0)
|
|
22
|
+
ethon (0.16.0)
|
|
23
|
+
ffi (>= 1.15.0)
|
|
24
|
+
faraday (2.7.11)
|
|
25
|
+
base64
|
|
26
|
+
faraday-net_http (>= 2.0, < 3.1)
|
|
27
|
+
ruby2_keywords (>= 0.0.4)
|
|
28
|
+
faraday-follow_redirects (0.3.0)
|
|
29
|
+
faraday (>= 1, < 3)
|
|
30
|
+
faraday-net_http (3.0.2)
|
|
31
|
+
ffi (1.16.3)
|
|
32
|
+
hashdiff (1.0.1)
|
|
33
|
+
hashie (5.0.0)
|
|
34
|
+
json (2.6.3)
|
|
35
|
+
jwt (2.7.1)
|
|
36
|
+
language_server-protocol (3.17.0.3)
|
|
37
|
+
method_source (1.0.0)
|
|
38
|
+
multi_xml (0.6.0)
|
|
39
|
+
oauth2 (2.0.9)
|
|
40
|
+
faraday (>= 0.17.3, < 3.0)
|
|
41
|
+
jwt (>= 1.0, < 3.0)
|
|
42
|
+
multi_xml (~> 0.5)
|
|
43
|
+
rack (>= 1.2, < 4)
|
|
44
|
+
snaky_hash (~> 2.0)
|
|
45
|
+
version_gem (~> 1.1)
|
|
46
|
+
parallel (1.23.0)
|
|
47
|
+
parser (3.2.2.4)
|
|
48
|
+
ast (~> 2.4.1)
|
|
49
|
+
racc
|
|
50
|
+
pkce_challenge (1.0.0)
|
|
51
|
+
pry (0.14.2)
|
|
52
|
+
coderay (~> 1.1)
|
|
53
|
+
method_source (~> 1.0)
|
|
54
|
+
pry-byebug (3.10.1)
|
|
55
|
+
byebug (~> 11.0)
|
|
56
|
+
pry (>= 0.13, < 0.15)
|
|
57
|
+
public_suffix (5.0.3)
|
|
58
|
+
racc (1.7.2)
|
|
59
|
+
rack (3.0.8)
|
|
60
|
+
rainbow (3.1.1)
|
|
61
|
+
rake (13.0.6)
|
|
62
|
+
regexp_parser (2.8.2)
|
|
63
|
+
rexml (3.2.6)
|
|
64
|
+
rspec (3.12.0)
|
|
65
|
+
rspec-core (~> 3.12.0)
|
|
66
|
+
rspec-expectations (~> 3.12.0)
|
|
67
|
+
rspec-mocks (~> 3.12.0)
|
|
68
|
+
rspec-core (3.12.2)
|
|
69
|
+
rspec-support (~> 3.12.0)
|
|
70
|
+
rspec-expectations (3.12.3)
|
|
71
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
72
|
+
rspec-support (~> 3.12.0)
|
|
73
|
+
rspec-mocks (3.12.6)
|
|
74
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
75
|
+
rspec-support (~> 3.12.0)
|
|
76
|
+
rspec-support (3.12.1)
|
|
77
|
+
rubocop (1.57.2)
|
|
78
|
+
json (~> 2.3)
|
|
79
|
+
language_server-protocol (>= 3.17.0)
|
|
80
|
+
parallel (~> 1.10)
|
|
81
|
+
parser (>= 3.2.2.4)
|
|
82
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
83
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
84
|
+
rexml (>= 3.2.5, < 4.0)
|
|
85
|
+
rubocop-ast (>= 1.28.1, < 2.0)
|
|
86
|
+
ruby-progressbar (~> 1.7)
|
|
87
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
|
88
|
+
rubocop-ast (1.30.0)
|
|
89
|
+
parser (>= 3.2.1.0)
|
|
90
|
+
rubocop-capybara (2.19.0)
|
|
91
|
+
rubocop (~> 1.41)
|
|
92
|
+
rubocop-factory_bot (2.24.0)
|
|
93
|
+
rubocop (~> 1.33)
|
|
94
|
+
rubocop-rake (0.6.0)
|
|
95
|
+
rubocop (~> 1.0)
|
|
96
|
+
rubocop-rspec (2.25.0)
|
|
97
|
+
rubocop (~> 1.40)
|
|
98
|
+
rubocop-capybara (~> 2.17)
|
|
99
|
+
rubocop-factory_bot (~> 2.22)
|
|
100
|
+
ruby-progressbar (1.13.0)
|
|
101
|
+
ruby2_keywords (0.0.5)
|
|
102
|
+
snaky_hash (2.0.1)
|
|
103
|
+
hashie
|
|
104
|
+
version_gem (~> 1.1, >= 1.1.1)
|
|
105
|
+
typhoeus (1.4.0)
|
|
106
|
+
ethon (>= 0.9.0)
|
|
107
|
+
unicode-display_width (2.5.0)
|
|
108
|
+
version_gem (1.1.3)
|
|
109
|
+
webmock (3.19.1)
|
|
110
|
+
addressable (>= 2.8.0)
|
|
111
|
+
crack (>= 0.3.2)
|
|
112
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
|
113
|
+
|
|
114
|
+
PLATFORMS
|
|
115
|
+
arm64-darwin-22
|
|
116
|
+
|
|
117
|
+
DEPENDENCIES
|
|
118
|
+
kinde_sdk!
|
|
119
|
+
pry-byebug
|
|
120
|
+
rake (~> 13.0.1)
|
|
121
|
+
rspec (~> 3.6, >= 3.6.0)
|
|
122
|
+
rubocop
|
|
123
|
+
rubocop-rake
|
|
124
|
+
rubocop-rspec
|
|
125
|
+
webmock
|
|
126
|
+
|
|
127
|
+
BUNDLED WITH
|
|
128
|
+
2.4.21
|
data/README.md
CHANGED
|
@@ -1,445 +1,23 @@
|
|
|
1
|
-
# Kinde Ruby SDK
|
|
1
|
+
# Kinde Ruby SDK
|
|
2
2
|
|
|
3
|
-
The Kinde
|
|
4
|
-
The gem contains all the related oauth2 authorization, so you need only to integrate it properly.
|
|
5
|
-
The gem contains 3 pre-built OAuth flows: **client credentials**, **authorization code** and **authorization code with PKCE code verifier**.
|
|
3
|
+
The Kinde SDK for Ruby.
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
You can also use the Ruby starter kit [here](https://github.com/kinde-starter-kits/ruby-starter-kit).
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
[](https://makeapullrequest.com) [](https://kinde.com/docs/developer-tools) [](https://thekindecommunity.slack.com)
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
## Documentation
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
For details on integrating this SDK into your project, head over to the [Kinde docs](https://kinde.com/docs/) and see the [Ruby SDK](https://kinde.com/docs/developer-tools/ruby-sdk) doc 👍🏼.
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
gem 'kinde_sdk', git: 'https://github.com/kinde-oss/kinde-ruby-sdk.git', branch: 'main'
|
|
18
|
-
```
|
|
19
|
-
or install manually through gem command.
|
|
13
|
+
## Publishing
|
|
20
14
|
|
|
21
|
-
|
|
15
|
+
The core team handles publishing.
|
|
22
16
|
|
|
23
|
-
|
|
17
|
+
## Contributing
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
Please refer to Kinde’s [contributing guidelines](https://github.com/kinde-oss/.github/blob/489e2ca9c3307c2b2e098a885e22f2239116394a/CONTRIBUTING.md).
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
## License
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
- **Allowed logout redirect URLs** - `http://localhost:3000`
|
|
31
|
-
|
|
32
|
-
Make sure you press the Save button at the bottom of the page!
|
|
33
|
-
|
|
34
|
-
_Note_: The `http://localhost:3000` is used as an example of local address, don't forget to add all the required addresses that you are going to use in any environments.
|
|
35
|
-
|
|
36
|
-
### Environments
|
|
37
|
-
|
|
38
|
-
If you would like to use our Environments feature as part of your development process. You will need to create them first within your Kinde account, see the guide here.
|
|
39
|
-
In this case you would use the Environment subdomain in the code block above.
|
|
40
|
-
|
|
41
|
-
### Configuring your app
|
|
42
|
-
|
|
43
|
-
In a basic scenario it requires several steps to be made:
|
|
44
|
-
1. proper configuring of client credentials and domain
|
|
45
|
-
2. external service authorization
|
|
46
|
-
3. callback processing
|
|
47
|
-
4. bearer token receiving
|
|
48
|
-
5. Usage
|
|
49
|
-
|
|
50
|
-
#### Integration
|
|
51
|
-
The gem contains simple configurator which you can use whenever you want. For example, in a typical Rails-app it can be
|
|
52
|
-
configured through initializer file:
|
|
53
|
-
|
|
54
|
-
```ruby
|
|
55
|
-
# domain, client_id/secret and callback defined somewhere in your settings
|
|
56
|
-
|
|
57
|
-
KindeSdk.configure do |c|
|
|
58
|
-
c.domain = domain
|
|
59
|
-
c.client_id = client_id
|
|
60
|
-
c.client_secret = client_secret
|
|
61
|
-
c.callback_url = callback_url
|
|
62
|
-
c.logout_url = logout_url
|
|
63
|
-
# c.scope = 'openid offline email profile' # default value
|
|
64
|
-
# c.pkce_enabled = true # default value
|
|
65
|
-
# c.authorize_url = '/oauth2/auth' # default value
|
|
66
|
-
# c.token_url = '/oauth2/token' # default value
|
|
67
|
-
# c.debugging = false # default value
|
|
68
|
-
# c.auto_refresh_tokens = true # default value
|
|
69
|
-
c.logger = Rails.logger
|
|
70
|
-
end
|
|
71
|
-
```
|
|
72
|
-
Snippet above contains all the possible configuration values.
|
|
73
|
-
Here is detailed explanation on them:
|
|
74
|
-
|
|
75
|
-
- `Domain` refers to your organization - for example, `your-biz.kinde.com`.
|
|
76
|
-
- `Client id` and `Client secret` can be fetched from your Kinde application credentials in a setting section.
|
|
77
|
-
- `Callback url` refers to your callback processing controller action. Remember that
|
|
78
|
-
the url must be defined in allowed callback urls of your kinde organization's [application config](#Kinde-configuration).
|
|
79
|
-
Callback url is an optional parameter, you can set the desired url in runtime, see examples below.
|
|
80
|
-
- `Logout url` will be triggered after successful logout on kinde. Same as callback url, it should be
|
|
81
|
-
defined in allowed logout urls of your kinde organization's application config
|
|
82
|
-
- `Scope` is an oauth special parameter which is used to limit some rights. Probably, you don't need to change in.
|
|
83
|
-
- `PKCE enabled` is a flag that can turn off PKCE auth flow. By default it is activated to improve your security.
|
|
84
|
-
- `Authorize url` and `Token url` are paths to oauth2 methods in kinde. You don't need to change it.
|
|
85
|
-
- `Debugging` set to true start writing verbose request logs. Might be useful while developing your application.
|
|
86
|
-
- `Logger` might be set to any kind of loggers you are using. By default it is set to `Rails.logger` if gem is used in
|
|
87
|
-
rails application or `Logger.new(STDOUT)` if it is not a rails app.
|
|
88
|
-
- `auto_refresh_tokens` defines default behaviour on api instance method calls. If the config set to false, there will not be any auto refreshes during method calling,
|
|
89
|
-
otherwise each time client will try to refresh expired tokens if `expires_at` are present (see [token expiration and refreshing](#token-expiration-and-refreshing) section).
|
|
90
|
-
|
|
91
|
-
These variables can be handled with any system you want: .env files, settings.yml or any type of config files.
|
|
92
|
-
For example, .env file (you can name variables by yourself):
|
|
93
|
-
```
|
|
94
|
-
KINDE_DOMAIN=https://example.kinde.com
|
|
95
|
-
KINDE_CLIENT_ID=qwe
|
|
96
|
-
KINDE_CLIENT_SECRET=wert
|
|
97
|
-
KINDE_CALLBACK_URL=http://localhost:3000/callback
|
|
98
|
-
KINDE_LOGOUT_URL=http://localhost:3000/logout_callback
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
can be used as:
|
|
102
|
-
```ruby
|
|
103
|
-
KindeSdk.configure do |c|
|
|
104
|
-
c.domain = ENV['KINDE_DOMAIN']
|
|
105
|
-
c.client_id = ENV['KINDE_CLIENT_ID']
|
|
106
|
-
# ....
|
|
107
|
-
end
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
#### Login / Register
|
|
111
|
-
The next step is to authorize you in the Kinde.
|
|
112
|
-
For this, you need to acquire auth url by calling:
|
|
113
|
-
```ruby
|
|
114
|
-
KindeSdk.auth_url
|
|
115
|
-
# =>
|
|
116
|
-
{
|
|
117
|
-
url: "https://<domain>/oauth2/auth?client_id=<client_id>&code_challenge=<generated code>&code_challenge_method=S256&redirect_uri=<redirect_uri>&response_type=code&scope=openid+offline+email+profile&state=<random string>",
|
|
118
|
-
code_verifier: "<challenge verifier>"
|
|
119
|
-
}
|
|
120
|
-
```
|
|
121
|
-
By default, gem uses PKCE verification flow - this means that in your auth url will be added special `code challenge`
|
|
122
|
-
param and the method returns verification string for the code, which should be used later in token acquiring request.
|
|
123
|
-
You are free to disable PKCE by setting `pkce_enabled` to false in your configuration.
|
|
124
|
-
In this case, `KindeSdk.auth_url` will return only url itself:
|
|
125
|
-
```ruby
|
|
126
|
-
KindeSdk.auth_url
|
|
127
|
-
# => {url: ......}
|
|
128
|
-
```
|
|
129
|
-
If you are about to use PCKE, our recommendation to save code verifier output somewhere near your later tokens output.
|
|
130
|
-
|
|
131
|
-
The `#auth_url` method can have another redirect url just in runtime. Use it with the argument:
|
|
132
|
-
```ruby
|
|
133
|
-
KindeSdk.auth_url(redirect_uri: "your-another-desired-callback")
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
You can put the link right in your web-application page or you can use it under the hood through redirection.
|
|
137
|
-
After visiting the link you'll be redirected to Kinde's sign in/sign up form.
|
|
138
|
-
And after authorizing in Kinde, you'll be redirected to callback url.
|
|
139
|
-
|
|
140
|
-
#### Handle redirect
|
|
141
|
-
Next step is to extract code from the callback redirection. Your callback endpoint should contain logic to call exchange method.
|
|
142
|
-
Callback will be triggered with body, where will be code present. You are free to use the whole `params` object or to extract code from `params["code"]`.
|
|
143
|
-
|
|
144
|
-
Next, it needs to be exchanged for the access and refresh tokens.
|
|
145
|
-
`code` is the parameter which received in the callback endpoint, `code_verifier` (if PKCE enabled) should be used from previous step:
|
|
146
|
-
```ruby
|
|
147
|
-
KindeSdk.fetch_tokens(code, code_verifier: code_verifier)
|
|
148
|
-
# =>
|
|
149
|
-
{"access_token"=>"eyJhbGciOiJSUzI1NiIsIm...",
|
|
150
|
-
"expires_in"=>86399,
|
|
151
|
-
"id_token"=>"eyJhbGciOiJSUz",
|
|
152
|
-
"refresh_token"=>"eyJhbGciOiJSUz",
|
|
153
|
-
"scope"=>"openid offline email profile",
|
|
154
|
-
"token_type"=>"bearer"}
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
This is your tokens - save the whole hash in your session, redis or any other storage and use it to build your client:
|
|
158
|
-
```ruby
|
|
159
|
-
# In case of preventing cookie overflow, you need to limit what exactly your are saving.
|
|
160
|
-
# Here is the required minimum of params. But in general you are able save it wherever you want to.
|
|
161
|
-
# For example, in database, without any limiting.
|
|
162
|
-
session[:kinde_auth] = KindeSdk.fetch_tokens(code).slice(:access_token, :id_token, :refresh_token, :expires_at)
|
|
163
|
-
# ...
|
|
164
|
-
client = KindeSdk.client(session[:kinde_auth]) # => #<KindeSdk::Client:0x00007faf31e5ecb8>
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
The `#fetch_tokens` method can have another callback url (just lake the `#auth_url` method), just use it in a same way:
|
|
168
|
-
```ruby
|
|
169
|
-
KindeSdk.fetch_tokens(code, redirect_uri: "your-another-desired-callback")
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
#### Token expiration and refreshing
|
|
173
|
-
For proper refreshing you'll need to use `access_token`, `refresh_token` and probably `expires_in` if you want to know is your access token still actual.
|
|
174
|
-
Use these two methods to work with refreshing:
|
|
175
|
-
```ruby
|
|
176
|
-
KindeSdk.token_expired?(session[:kinde_auth]) # => false
|
|
177
|
-
KindeSdk.refresh_token(session[:kinde_auth]) # => {"access_token" => "qwe...", "refresh_token" => "fqw...", "expires_at"=>1685474405}
|
|
178
|
-
```
|
|
179
|
-
or from your client instance:
|
|
180
|
-
```ruby
|
|
181
|
-
client.token_expired? # => false
|
|
182
|
-
client.refresh_token # => {"access_token" => "qwe...", ...., "expires_at"=>1685474405}
|
|
183
|
-
```
|
|
184
|
-
If you are calling `#refresh_token` on a client instance, the instance token data will be automatically updated.
|
|
185
|
-
If you are calling `KindeSdk#refresh_token`, you'll need to store new token data in your configured storage (redis/session/etc).
|
|
186
|
-
|
|
187
|
-
**Warning!**
|
|
188
|
-
Each instance_api method checking tokens for expiration if expires_at present in a hash.
|
|
189
|
-
So, if in your backend code you are using some storage, be sure you are saving `client.tokens_hash` after each instance
|
|
190
|
-
method calling, otherwise you will keep in your storage (session/redis/etc.) old data and unable to fetch new tokens.
|
|
191
|
-
|
|
192
|
-
If you don't want auto refreshing behavior, set `auto_refresh_tokens` config to false.
|
|
193
|
-
|
|
194
|
-
#### Audience
|
|
195
|
-
An `audience` is the intended recipient of an access token - for example the API for your application.
|
|
196
|
-
The audience argument can be passed to the Kinde `#auth_url` method to request an audience be added to the provided token:
|
|
197
|
-
```ruby
|
|
198
|
-
KindeSdk.auth_url(audience: "https://your-app.kinde.com/api")
|
|
199
|
-
```
|
|
200
|
-
For details on how to connect, see [Register an API](https://kinde.com/docs/developer-tools/register-an-api/)
|
|
201
|
-
|
|
202
|
-
#### Overriding scope
|
|
203
|
-
By default `KindeSdk` requests the following scopes:
|
|
204
|
-
|
|
205
|
-
- profile
|
|
206
|
-
- email
|
|
207
|
-
- offline
|
|
208
|
-
- openid
|
|
209
|
-
|
|
210
|
-
You are able to change it - by configuring as mentioned at [Integration](#integration) or by direct param passing into `auth_url` method:
|
|
211
|
-
```ruby
|
|
212
|
-
KindeSdk.auth_url(scope: "openid offline")
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
#### Getting claims
|
|
216
|
-
We have provided a helper to grab any claim from your id or access tokens. The helper defaults to access tokens:
|
|
217
|
-
```ruby
|
|
218
|
-
client = KindeSdk.client(session[:kinde_auth])
|
|
219
|
-
client.get_claim("aud") #=> {name: "aud", value: ['api.yourapp.com']}
|
|
220
|
-
client.get_claim("scp") #=> {name: "scp", value: ["openid", "offline"]}
|
|
221
|
-
```
|
|
222
|
-
By default claim data fetched from access_token, but you can also do it with id_token as well:
|
|
223
|
-
```ruby
|
|
224
|
-
client.get_claim("some-claim", :id_token) # => {name: "some-claim", value: "some-data"}
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
#### User permissions
|
|
228
|
-
After a user signs in and they are verified, the token return includes permissions for that user.
|
|
229
|
-
[User permissions](https://kinde.com/docs/user-management/user-permissions) are set in Kinde,
|
|
230
|
-
but you must also configure your application to unlock these functions.
|
|
231
|
-
```
|
|
232
|
-
permissions" => [
|
|
233
|
-
"create:todos",
|
|
234
|
-
"update:todos",
|
|
235
|
-
"read:todos",
|
|
236
|
-
"delete:todos",
|
|
237
|
-
"create:tasks",
|
|
238
|
-
"update:tasks",
|
|
239
|
-
"read:tasks",
|
|
240
|
-
"delete:tasks",
|
|
241
|
-
]
|
|
242
|
-
```
|
|
243
|
-
We provide helper functions to more easily access permissions:
|
|
244
|
-
```ruby
|
|
245
|
-
client = KindeSdk.client(session[:kinde_auth])
|
|
246
|
-
client.get_permission("create:todos") # => {org_code: "org_1234", is_granted: true}
|
|
247
|
-
client.permission_granted?("create:todos") # => true
|
|
248
|
-
client.permission_granted?("create:orders") # => false
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
#### Feature flags
|
|
252
|
-
Kinde itself provides feature flag functionality - more [here](https://kinde.com/feature-flags/).
|
|
253
|
-
So, the SDK provides methods to work with them.
|
|
254
|
-
For example, you have data like below:
|
|
255
|
-
```json
|
|
256
|
-
{
|
|
257
|
-
"asd": { "t": "b", "v": true },
|
|
258
|
-
"eeeeee": { "t": "i", "v": 111 },
|
|
259
|
-
"qqq": { "t": "s", "v": "aa" }
|
|
260
|
-
}
|
|
261
|
-
```
|
|
262
|
-
where `t` refers to type (`b` - boolean, `i` - integer, `s` - string) and `v` refers to value.
|
|
263
|
-
You can fetch these flags with methods below:
|
|
264
|
-
```ruby
|
|
265
|
-
client.get_flag("asd") # => { code: "asd", is_default: false, type: "boolean", value: true }
|
|
266
|
-
client.get_flag("eeeeee") # => { code: "eeeeee", is_default: false, type: "integer", value: 111 }
|
|
267
|
-
client.get_flag("qqq") # => { code: "qqq", is_default: false, type: "string", value: "aa" }
|
|
268
|
-
```
|
|
269
|
-
Note that trying to call undefined flag leads to exception.
|
|
270
|
-
|
|
271
|
-
In addition to fetch existing flags, you can use fallbacks. For example:
|
|
272
|
-
```ruby
|
|
273
|
-
client.get_flag("undefined", { default_value: true }) # => { code: "undefined", is_default: true, value: true }
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
and with setting the type explicitly (output omitted except value):
|
|
277
|
-
```ruby
|
|
278
|
-
client.get_flag("undefined_bool", { default_value: true }, "b") # => value = true
|
|
279
|
-
client.get_flag("undefined_string", { default_value: "true" }, "s") # => value = "true"
|
|
280
|
-
client.get_flag("undefined_int", { default_value: 111 }, "i") # => value = 111
|
|
281
|
-
```
|
|
282
|
-
In the example above if you try to set default_value of different type (for example: `get_flag("flag", {default_value: 1}, "s")`), you'll get an exception.
|
|
283
|
-
|
|
284
|
-
Also you have wrapper methods, for example:
|
|
285
|
-
```ruby
|
|
286
|
-
client.get_boolean_flag("eeeeee") # => leads to exception "Flag eeeeee value type is different from requested type"
|
|
287
|
-
client.get_boolean_flag("asd") # => true
|
|
288
|
-
client.get_boolean_flag("undefined", false) # => false
|
|
289
|
-
|
|
290
|
-
client.get_integer_flag("asd") # => exception "Flag asd value type is different from requested type"
|
|
291
|
-
client.get_integer_flag("undefined", "true") # => exception "Flag undefined value type is different from requested type"
|
|
292
|
-
client.get_integer_flag("eeeeee") # => 111
|
|
293
|
-
client.get_integer_flag("undefined", 123) # => 123
|
|
294
|
-
|
|
295
|
-
client.get_string_flag("qqq") # => "aa"
|
|
296
|
-
client.get_string_flag("undefined", "111") # => "111"
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
#### Client usage
|
|
300
|
-
API part is mounted in the `KindeSdk::Client` instance, so the short usage is just simple as:
|
|
301
|
-
```ruby
|
|
302
|
-
client.oauth.get_user
|
|
303
|
-
client.users.create_user(args)
|
|
304
|
-
client.organizations.get_organizations
|
|
305
|
-
```
|
|
306
|
-
The method name will be the same as API module from sdk without `-Api` part in the end.
|
|
307
|
-
Alternatively, you can initialize each API module by yourself:
|
|
308
|
-
```ruby
|
|
309
|
-
# use initialized and configured api client
|
|
310
|
-
api_client = KindeSdk.api_client(access_token)
|
|
311
|
-
instance_client = KindeApi::UsersApi.new(api_client)
|
|
312
|
-
instance_client.create_user(args)
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
#### Logout
|
|
316
|
-
For logout you need to call (in case of rails app) in your controller:
|
|
317
|
-
```ruby
|
|
318
|
-
redirect_to KindeSdk.logout_url, allow_other_host: true
|
|
319
|
-
```
|
|
320
|
-
Your app should handle logout callback url (which was configured separately).
|
|
321
|
-
After calling redirect to logout_url (if set), Kinde redirect it back to logout callback path, where you need to clear your session:
|
|
322
|
-
```ruby
|
|
323
|
-
# .......
|
|
324
|
-
def logout_callback
|
|
325
|
-
Rails.logger.info("logout callback successfully received")
|
|
326
|
-
reset_session
|
|
327
|
-
redirect_to root_path
|
|
328
|
-
end
|
|
329
|
-
# ......
|
|
330
|
-
```
|
|
331
|
-
If you configured logout redirect url correct (e.g. added in the admin panel allowed logout redirect), you can receive
|
|
332
|
-
a logout callback. Otherwise Kinde logout message will be shown.
|
|
333
|
-
|
|
334
|
-
### Organizations
|
|
335
|
-
#### Create an organization
|
|
336
|
-
To have a new organization created within your application, you will need to run something like:
|
|
337
|
-
```ruby
|
|
338
|
-
client.organizations.create_organization(create_organization_request: {name: "new_org"})
|
|
339
|
-
# or `client.organizations.create_organization` without name
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
### Sign up and sign in to organizations
|
|
343
|
-
Kinde has a unique code for every organization.
|
|
344
|
-
If you want a user to sign into a particular organization, call the `#auth_url` method with `org_code` param passing:
|
|
345
|
-
```ruby
|
|
346
|
-
KindeSdk.auth_url(org_code: "org_1234", start_page: "registration") # to enforce new user creation form
|
|
347
|
-
KindeSdk.auth_url(org_code: "org_1234") # to login by default
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
Following authentication, Kinde provides a json web token (jwt) to your application.
|
|
351
|
-
Along with the standard information we also include the `org_code` and the permissions for that organization (this is important as a user can belong to multiple organizations and have different permissions for each).
|
|
352
|
-
|
|
353
|
-
Example of a returned token:
|
|
354
|
-
```ruby
|
|
355
|
-
[
|
|
356
|
-
{
|
|
357
|
-
"aud" => [],
|
|
358
|
-
"exp" => 1658475930,
|
|
359
|
-
"iat" => 1658472329,
|
|
360
|
-
"iss" => "https://your_subdomain.kinde.com",
|
|
361
|
-
"jti" => "123457890",
|
|
362
|
-
"org_code" => "org_1234",
|
|
363
|
-
"permissions" => ["read:todos", "create:todos"],
|
|
364
|
-
"scp" => [
|
|
365
|
-
"openid",
|
|
366
|
-
"profile",
|
|
367
|
-
"email",
|
|
368
|
-
"offline"
|
|
369
|
-
],
|
|
370
|
-
"sub" => "kp:123457890",
|
|
371
|
-
"feature_flags" => {
|
|
372
|
-
"asd" => { "t" => "b", "v" => true },
|
|
373
|
-
"eeeeee" => { "t" => "i", "v" => 111 },
|
|
374
|
-
"qqq" => { "t" => "s", "v" => "aa" }
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
]
|
|
378
|
-
```
|
|
379
|
-
The `id_token` will also contain an array of organizations that a user belongs to - this is useful if you wanted to build out an organization switcher for example:
|
|
380
|
-
```ruby
|
|
381
|
-
client.get_claim("org_codes", :id_token) # => {name: "org_codes", value: ["org_1234", "org_5462"]}
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
### API reference
|
|
385
|
-
Detailed API reference described in [KindeSDK README](kinde-sdk/README.md) and underlying description docs.
|
|
386
|
-
Here are some selected examples of usage.
|
|
387
|
-
|
|
388
|
-
#### Getting user info
|
|
389
|
-
|
|
390
|
-
```ruby
|
|
391
|
-
KindeSdk.client(session[:kinde_auth]).oauth.get_user
|
|
392
|
-
# => {id: ..., preferred_email: ..., provided_id: ..., last_name: ..., first_name: ...}
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
#### Management API
|
|
396
|
-
These sections below are part of management API. It should be configured first at your Kinde account
|
|
397
|
-
[Here is detailed note about it](https://kinde.notion.site/Management-API-via-client_credentials-240e6fa548c144828d4981ddbaa0f6b2),
|
|
398
|
-
you need to add `Machine to Machine` (M2M) application and use another grant type for authorization:
|
|
399
|
-
```ruby
|
|
400
|
-
result = KindeSdk.client_credentials_access(
|
|
401
|
-
client_id: ENV["KINDE_MANAGEMENT_CLIENT_ID"],
|
|
402
|
-
client_secret: ENV["KINDE_MANAGEMENT_CLIENT_SECRET"]
|
|
403
|
-
)
|
|
404
|
-
# as an example of usage redis to save access token:
|
|
405
|
-
$redis.set("kinde_m2m_token", result["access_token"], ex: result["expires_in"].to_i)
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
##### Organizations handling
|
|
409
|
-
```ruby
|
|
410
|
-
client = KindeSdk.client({"access_token" => $redis.get("kinde_m2m_token")})
|
|
411
|
-
# get organizations list:
|
|
412
|
-
client.organizations.get_organizations
|
|
413
|
-
# => {"code": "OK", "message": "Success", "next_token": "qweqweqwe", "organizations": [{"code": "org_casda123c", "name": "Default Organization", "is_default": true}]}
|
|
414
|
-
|
|
415
|
-
# create new organization:
|
|
416
|
-
client.organizations.create_organization(create_organization_request: {name: "new_org"})
|
|
417
|
-
# this variant for more strict input params validation:
|
|
418
|
-
# client.organizations.create_organization(create_organization_request: KindeApi::CreateOrganizationRequest.new(name: new_org_name))
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
#### Create new user
|
|
422
|
-
```ruby
|
|
423
|
-
client.users.create_user(
|
|
424
|
-
create_user_request: {
|
|
425
|
-
profile: {given_name: "AAAname", family_name: "AAAsurname"},
|
|
426
|
-
identities: [{type: "email", details: {email: "aaexample@asd.com"}}]
|
|
427
|
-
}
|
|
428
|
-
)
|
|
429
|
-
```
|
|
430
|
-
Alternatively, using model instances:
|
|
431
|
-
```ruby
|
|
432
|
-
request = KindeApi::CreateUserRequest.new(
|
|
433
|
-
profile: KindeApi::CreateUserRequestProfile.new(given_name: "AAAfirstname1", family_name: "AAAlastname1"),
|
|
434
|
-
identities: [
|
|
435
|
-
KindeApi::CreateUserRequestIdentitiesInner.new(type: "email", details: KindeApi::CreateUserRequestIdentitiesInnerDetails.new(email: "aaaaexample@example.com"))
|
|
436
|
-
]
|
|
437
|
-
)
|
|
438
|
-
client.users.create_user(create_user_request: request)
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
#### Add organization users
|
|
442
|
-
|
|
443
|
-
```ruby
|
|
444
|
-
client.organizations.add_organization_users(code: "org_1111", users: ["kp:12311...."])
|
|
445
|
-
```
|
|
23
|
+
By contributing to Kinde, you agree that your contributions will be licensed under its MIT License.
|