Skip to content

Commit

Permalink
Merge pull request #260 from okta/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiibuniak-okta authored Nov 16, 2021
2 parents 691e18f + 7c23202 commit 45366dd
Show file tree
Hide file tree
Showing 107 changed files with 6,392 additions and 363 deletions.
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
# Okta Python SDK Changelog

## v2.3.0
- Regenerate code using the [open API spec v2.9.1](https://github.com/okta/okta-management-openapi-spec/releases/tag/openapi-2.9.1).
- Allow next for all requests
- Allow upload files within FormData
- Add updateOrgLogo operation to Org resource (Org appeared in v2.2.0)
- Allow custom SSL Context settings

_New resources:_
* Brand

_New models:_
AccessPolicy
AccessPolicyConstraint
AccessPolicyConstraints
AccessPolicyRule
AccessPolicyRuleActions
AccessPolicyRuleApplicationSignOn
AccessPolicyRuleConditions
AccessPolicyRuleCustomCondition
AuthenticatorProvider
AuthenticatorProviderConfiguration
AuthenticatorProviderConfigurationUserNamePlate
Brand
ChannelBinding
Compliance
DeviceAccessPolicyRuleCondition
EmailTemplateTouchPointVariant
EndUserDashboardTouchPointVariant
ErrorPageTouchPointVariant
FipsEnum
ImageUploadResponse
KnowledgeConstraint
PossessionConstraint
PreRegistrationInlineHook
ProfileEnrollmentPolicy
ProfileEnrollmentPolicyRule
ProfileEnrollmentPolicyRuleAction
ProfileEnrollmentPolicyRuleActions
ProfileEnrollmentPolicyRuleActivationRequirement
ProfileEnrollmentPolicyRuleProfileAttribute
RequiredEnum
SignInPageTouchPointVariant
Theme
ThemeResponse
UserTypeCondition
UserVerificationEnum
VerificationMethod

## v2.2.0
- Regenerate code using the [open API spec v2.7.0](https://github.com/okta/okta-management-openapi-spec/releases/tag/openapi-2.7.0).
- Allow Bearer auth
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,28 @@ Each one of the configuration values above can be turned into an environment var
- `OKTA_CLIENT_RATELIMIT_MAXRETRIES`
- `OKTA_TESTING_TESTINGDISABLEHTTPSCHECK`

### Other configuration options

Starting with SDK v2.3.0 you can provide custom SSL context:

```py
import asyncio
import ssl
from okta.client import Client as OktaClient
async def main():
# create default context for demo purpose
ssl_context = ssl.create_default_context()
client = OktaClient({"sslContext": ssl_context})
users, resp, err = await client.list_users()
print(users)
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
```

## Rate Limiting

The Okta API will return 429 responses if too many requests are made within a given time. Please see [Rate Limiting at Okta][rate-limiting-okta] for a complete list of which endpoints are rate limited. When a 429 error is received, the X-Rate-Limit-Reset header will tell you the time at which you can retry. This section discusses the method for handling rate limiting with this SDK.
Expand Down
2 changes: 1 addition & 1 deletion okta/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.2.0'
__version__ = '2.3.0'
8 changes: 3 additions & 5 deletions okta/api_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import xmltodict

from okta.api_client import APIClient
from okta.utils import convert_absolute_url_into_relative_url


class OktaAPIResponse():
Expand Down Expand Up @@ -104,15 +105,12 @@ def extract_pagination(self, links):
links (dict): Dictionary object of values in the 'Link' header
"""

API = "/api/"
# Check for 'self' link
if "self" in links:
self._self = API + \
links["self"]["url"].human_repr().partition(API)[2]
self._self = convert_absolute_url_into_relative_url(links["self"]["url"].human_repr())
# Check for 'next' link
if "next" in links:
self._next = API + \
links["next"]["url"].human_repr().partition(API)[2]
self._next = convert_absolute_url_into_relative_url(links["next"]["url"].human_repr())

def has_next(self):
"""
Expand Down
3 changes: 3 additions & 0 deletions okta/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import AuthenticatorClient
from okta.resource_clients.authorization_server_client\
import AuthorizationServerClient
from okta.resource_clients.brand_client\
import BrandClient
from okta.resource_clients.domain_client\
import DomainClient
from okta.resource_clients.event_hook_client\
Expand Down Expand Up @@ -79,6 +81,7 @@ class Client(
ApplicationClient,
AuthenticatorClient,
AuthorizationServerClient,
BrandClient,
DomainClient,
EventHookClient,
FeatureClient,
Expand Down
6 changes: 5 additions & 1 deletion okta/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ def find_factor_model(factor_type):


OKTA_POLICY_TYPE_TO_MODEL = {
PT.ACCESS_POLICY: models.AccessPolicy,
PT.IDP_DISCOVERY: models.IdentityProviderPolicy,
PT.OAUTH_AUTHORIZATION_POLICY: models.OAuthAuthorizationPolicy,
PT.OKTA_SIGN_ON: models.OktaSignOnPolicy,
PT.PASSWORD: models.PasswordPolicy
PT.PASSWORD: models.PasswordPolicy,
PT.PROFILE_ENROLLMENT: models.ProfileEnrollmentPolicy
}


Expand All @@ -89,7 +91,9 @@ def find_policy_model(policy_type):


OKTA_POLICY_RULE_TYPE_TO_MODEL = {
"ACCESS_POLICY": models.AccessPolicyRule,
"PASSWORD": models.PasswordPolicyRule,
"PROFILE_ENROLLMENT": models.ProfileEnrollmentPolicyRule,
"SIGN_ON": models.OktaSignOnPolicyRule
}

Expand Down
19 changes: 14 additions & 5 deletions okta/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def __init__(self, http_config={}):
self._proxy = self._setup_proxy(http_config["proxy"])
else:
self._proxy = None
if "sslContext" in http_config:
self._ssl_context = http_config["sslContext"]
else:
self._ssl_context = None

async def send_request(self, request):
"""
Expand All @@ -57,6 +61,8 @@ async def send_request(self, request):
'headers': self._default_headers}
if request['data']:
params['data'] = json.dumps(request['data'])
elif request['form']:
params['data'] = request['form']
json_data = request.get('json')
# empty json param may cause issue, so include it if needed only
# more details: https://github.com/okta/okta-sdk-python/issues/131
Expand All @@ -66,12 +72,15 @@ async def send_request(self, request):
params['timeout'] = self._timeout
if self._proxy:
params['proxy'] = self._proxy
if self._ssl_context:
params['ssl_context'] = self._ssl_context
# Fire request
async with aiohttp.request(**params) as response:
return (response.request_info,
response,
await response.text(),
None)
async with aiohttp.ClientSession() as session:
async with session.request(**params) as response:
return (response.request_info,
response,
await response.text(),
None)
except (aiohttp.ClientError, asyncio.TimeoutError) as error:
# Return error if arises
logger.exception(error)
Expand Down
72 changes: 72 additions & 0 deletions okta/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@
# AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY
# SEE CONTRIBUTOR DOCUMENTATION

from okta.models import access_policy as access_policy
AccessPolicy = access_policy.AccessPolicy
from okta.models import access_policy_constraint as access_policy_constraint
AccessPolicyConstraint = access_policy_constraint.AccessPolicyConstraint
from okta.models import access_policy_constraints as access_policy_constraints
AccessPolicyConstraints = access_policy_constraints.AccessPolicyConstraints
from okta.models import access_policy_rule as access_policy_rule
AccessPolicyRule = access_policy_rule.AccessPolicyRule
from okta.models import access_policy_rule_actions as access_policy_rule_actions
AccessPolicyRuleActions = access_policy_rule_actions.AccessPolicyRuleActions
from okta.models import access_policy_rule_application_sign_on as access_policy_rule_application_sign_on
AccessPolicyRuleApplicationSignOn = access_policy_rule_application_sign_on.AccessPolicyRuleApplicationSignOn
from okta.models import access_policy_rule_conditions as access_policy_rule_conditions
AccessPolicyRuleConditions = access_policy_rule_conditions.AccessPolicyRuleConditions
from okta.models import access_policy_rule_custom_condition as access_policy_rule_custom_condition
AccessPolicyRuleCustomCondition = access_policy_rule_custom_condition.AccessPolicyRuleCustomCondition
from okta.models import acs_endpoint as acs_endpoint
AcsEndpoint = acs_endpoint.AcsEndpoint
from okta.models import activate_factor_request as activate_factor_request
Expand Down Expand Up @@ -84,6 +100,12 @@
AuthenticationProviderType = authentication_provider_type.AuthenticationProviderType
from okta.models import authenticator as authenticator
Authenticator = authenticator.Authenticator
from okta.models import authenticator_provider as authenticator_provider
AuthenticatorProvider = authenticator_provider.AuthenticatorProvider
from okta.models import authenticator_provider_configuration as authenticator_provider_configuration
AuthenticatorProviderConfiguration = authenticator_provider_configuration.AuthenticatorProviderConfiguration
from okta.models import authenticator_provider_configuration_user_name_plate as authenticator_provider_configuration_user_name_plate
AuthenticatorProviderConfigurationUserNamePlate = authenticator_provider_configuration_user_name_plate.AuthenticatorProviderConfigurationUserNamePlate
from okta.models import authenticator_settings as authenticator_settings
AuthenticatorSettings = authenticator_settings.AuthenticatorSettings
from okta.models import authenticator_status as authenticator_status
Expand Down Expand Up @@ -128,6 +150,8 @@
BookmarkApplicationSettings = bookmark_application_settings.BookmarkApplicationSettings
from okta.models import bookmark_application_settings_application as bookmark_application_settings_application
BookmarkApplicationSettingsApplication = bookmark_application_settings_application.BookmarkApplicationSettingsApplication
from okta.models import brand as brand
Brand = brand.Brand
from okta.models import browser_plugin_application as browser_plugin_application
BrowserPluginApplication = browser_plugin_application.BrowserPluginApplication
from okta.models import call_user_factor as call_user_factor
Expand All @@ -140,8 +164,12 @@
CatalogApplicationStatus = catalog_application_status.CatalogApplicationStatus
from okta.models import change_password_request as change_password_request
ChangePasswordRequest = change_password_request.ChangePasswordRequest
from okta.models import channel_binding as channel_binding
ChannelBinding = channel_binding.ChannelBinding
from okta.models import client_policy_condition as client_policy_condition
ClientPolicyCondition = client_policy_condition.ClientPolicyCondition
from okta.models import compliance as compliance
Compliance = compliance.Compliance
from okta.models import context_policy_rule_condition as context_policy_rule_condition
ContextPolicyRuleCondition = context_policy_rule_condition.ContextPolicyRuleCondition
from okta.models import create_session_request as create_session_request
Expand All @@ -164,6 +192,8 @@
DnsRecord = dns_record.DnsRecord
from okta.models import dns_record_type as dns_record_type
DnsRecordType = dns_record_type.DnsRecordType
from okta.models import device_access_policy_rule_condition as device_access_policy_rule_condition
DeviceAccessPolicyRuleCondition = device_access_policy_rule_condition.DeviceAccessPolicyRuleCondition
from okta.models import device_policy_rule_condition as device_policy_rule_condition
DevicePolicyRuleCondition = device_policy_rule_condition.DevicePolicyRuleCondition
from okta.models import device_policy_rule_condition_platform as device_policy_rule_condition_platform
Expand All @@ -184,12 +214,18 @@
DomainValidationStatus = domain_validation_status.DomainValidationStatus
from okta.models import duration as duration
Duration = duration.Duration
from okta.models import email_template_touch_point_variant as email_template_touch_point_variant
EmailTemplateTouchPointVariant = email_template_touch_point_variant.EmailTemplateTouchPointVariant
from okta.models import email_user_factor as email_user_factor
EmailUserFactor = email_user_factor.EmailUserFactor
from okta.models import email_user_factor_profile as email_user_factor_profile
EmailUserFactorProfile = email_user_factor_profile.EmailUserFactorProfile
from okta.models import enabled_status as enabled_status
EnabledStatus = enabled_status.EnabledStatus
from okta.models import end_user_dashboard_touch_point_variant as end_user_dashboard_touch_point_variant
EndUserDashboardTouchPointVariant = end_user_dashboard_touch_point_variant.EndUserDashboardTouchPointVariant
from okta.models import error_page_touch_point_variant as error_page_touch_point_variant
ErrorPageTouchPointVariant = error_page_touch_point_variant.ErrorPageTouchPointVariant
from okta.models import event_hook as event_hook
EventHook = event_hook.EventHook
from okta.models import event_hook_channel as event_hook_channel
Expand Down Expand Up @@ -222,6 +258,8 @@
FeatureStageValue = feature_stage_value.FeatureStageValue
from okta.models import feature_type as feature_type
FeatureType = feature_type.FeatureType
from okta.models import fips_enum as fips_enum
FipsEnum = fips_enum.FipsEnum
from okta.models import forgot_password_response as forgot_password_response
ForgotPasswordResponse = forgot_password_response.ForgotPasswordResponse
from okta.models import grant_type_policy_rule_condition as grant_type_policy_rule_condition
Expand Down Expand Up @@ -286,6 +324,8 @@
IdentityProviderPolicy = identity_provider_policy.IdentityProviderPolicy
from okta.models import identity_provider_policy_rule_condition as identity_provider_policy_rule_condition
IdentityProviderPolicyRuleCondition = identity_provider_policy_rule_condition.IdentityProviderPolicyRuleCondition
from okta.models import image_upload_response as image_upload_response
ImageUploadResponse = image_upload_response.ImageUploadResponse
from okta.models import inactivity_policy_rule_condition as inactivity_policy_rule_condition
InactivityPolicyRuleCondition = inactivity_policy_rule_condition.InactivityPolicyRuleCondition
from okta.models import inline_hook as inline_hook
Expand Down Expand Up @@ -318,6 +358,8 @@
JsonWebKey = json_web_key.JsonWebKey
from okta.models import jwk_use as jwk_use
JwkUse = jwk_use.JwkUse
from okta.models import knowledge_constraint as knowledge_constraint
KnowledgeConstraint = knowledge_constraint.KnowledgeConstraint
from okta.models import lifecycle_expiration_policy_rule_condition as lifecycle_expiration_policy_rule_condition
LifecycleExpirationPolicyRuleCondition = lifecycle_expiration_policy_rule_condition.LifecycleExpirationPolicyRuleCondition
from okta.models import linked_object as linked_object
Expand Down Expand Up @@ -562,6 +604,22 @@
PolicyType = policy_type.PolicyType
from okta.models import policy_user_name_template as policy_user_name_template
PolicyUserNameTemplate = policy_user_name_template.PolicyUserNameTemplate
from okta.models import possession_constraint as possession_constraint
PossessionConstraint = possession_constraint.PossessionConstraint
from okta.models import pre_registration_inline_hook as pre_registration_inline_hook
PreRegistrationInlineHook = pre_registration_inline_hook.PreRegistrationInlineHook
from okta.models import profile_enrollment_policy as profile_enrollment_policy
ProfileEnrollmentPolicy = profile_enrollment_policy.ProfileEnrollmentPolicy
from okta.models import profile_enrollment_policy_rule as profile_enrollment_policy_rule
ProfileEnrollmentPolicyRule = profile_enrollment_policy_rule.ProfileEnrollmentPolicyRule
from okta.models import profile_enrollment_policy_rule_action as profile_enrollment_policy_rule_action
ProfileEnrollmentPolicyRuleAction = profile_enrollment_policy_rule_action.ProfileEnrollmentPolicyRuleAction
from okta.models import profile_enrollment_policy_rule_actions as profile_enrollment_policy_rule_actions
ProfileEnrollmentPolicyRuleActions = profile_enrollment_policy_rule_actions.ProfileEnrollmentPolicyRuleActions
from okta.models import profile_enrollment_policy_rule_activation_requirement as profile_enrollment_policy_rule_activation_requirement
ProfileEnrollmentPolicyRuleActivationRequirement = profile_enrollment_policy_rule_activation_requirement.ProfileEnrollmentPolicyRuleActivationRequirement
from okta.models import profile_enrollment_policy_rule_profile_attribute as profile_enrollment_policy_rule_profile_attribute
ProfileEnrollmentPolicyRuleProfileAttribute = profile_enrollment_policy_rule_profile_attribute.ProfileEnrollmentPolicyRuleProfileAttribute
from okta.models import profile_mapping as profile_mapping
ProfileMapping = profile_mapping.ProfileMapping
from okta.models import profile_mapping_property as profile_mapping_property
Expand Down Expand Up @@ -604,6 +662,8 @@
PushUserFactorProfile = push_user_factor_profile.PushUserFactorProfile
from okta.models import recovery_question_credential as recovery_question_credential
RecoveryQuestionCredential = recovery_question_credential.RecoveryQuestionCredential
from okta.models import required_enum as required_enum
RequiredEnum = required_enum.RequiredEnum
from okta.models import reset_password_token as reset_password_token
ResetPasswordToken = reset_password_token.ResetPasswordToken
from okta.models import response_links as response_links
Expand Down Expand Up @@ -658,6 +718,8 @@
SessionIdentityProviderType = session_identity_provider_type.SessionIdentityProviderType
from okta.models import session_status as session_status
SessionStatus = session_status.SessionStatus
from okta.models import sign_in_page_touch_point_variant as sign_in_page_touch_point_variant
SignInPageTouchPointVariant = sign_in_page_touch_point_variant.SignInPageTouchPointVariant
from okta.models import sign_on_inline_hook as sign_on_inline_hook
SignOnInlineHook = sign_on_inline_hook.SignOnInlineHook
from okta.models import single_logout as single_logout
Expand Down Expand Up @@ -690,6 +752,10 @@
SwaThreeFieldApplicationSettingsApplication = swa_three_field_application_settings_application.SwaThreeFieldApplicationSettingsApplication
from okta.models import temp_password as temp_password
TempPassword = temp_password.TempPassword
from okta.models import theme as theme
Theme = theme.Theme
from okta.models import theme_response as theme_response
ThemeResponse = theme_response.ThemeResponse
from okta.models import threat_insight_configuration as threat_insight_configuration
ThreatInsightConfiguration = threat_insight_configuration.ThreatInsightConfiguration
from okta.models import token_authorization_server_policy_rule_action as token_authorization_server_policy_rule_action
Expand Down Expand Up @@ -778,6 +844,12 @@
UserStatusPolicyRuleCondition = user_status_policy_rule_condition.UserStatusPolicyRuleCondition
from okta.models import user_type as user_type
UserType = user_type.UserType
from okta.models import user_type_condition as user_type_condition
UserTypeCondition = user_type_condition.UserTypeCondition
from okta.models import user_verification_enum as user_verification_enum
UserVerificationEnum = user_verification_enum.UserVerificationEnum
from okta.models import verification_method as verification_method
VerificationMethod = verification_method.VerificationMethod
from okta.models import verify_factor_request as verify_factor_request
VerifyFactorRequest = verify_factor_request.VerifyFactorRequest
from okta.models import verify_user_factor_response as verify_user_factor_response
Expand Down
Loading

0 comments on commit 45366dd

Please sign in to comment.