Skip to content

Commit

Permalink
adding dev-v0.25.1 tag to this commit to ensure building
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Nov 11, 2024
1 parent 85a2b7d commit b59f23e
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,21 @@ <h1 class="title">Module <code>supertokens_python.recipe.dashboard.api.multitena

additional_config: Optional[Dict[str, Any]] = None

# filter out providers that is not matching thirdPartyId
providers_from_core = [
provider
for provider in providers_from_core
if provider.third_party_id == third_party_id
]

if not providers_from_core:
# if none left, add one to this list so that it takes priority while merging
if len(providers_from_core) == 0:
providers_from_core.append(ProviderConfig(third_party_id=third_party_id))

# At this point, providersFromCore.length === 1

# query param may be passed if we are creating a new third party config, check and update accordingly

if third_party_id in [&#34;okta&#34;, &#34;active-directory&#34;, &#34;boxy-saml&#34;, &#34;google-workspaces&#34;]:
if third_party_id == &#34;okta&#34;:
okta_domain = options.request.get_query_param(&#34;oktaDomain&#34;)
Expand Down Expand Up @@ -163,28 +169,19 @@ <h1 class="title">Module <code>supertokens_python.recipe.dashboard.api.multitena

if providers_from_core[0].clients is not None:
for existing_client in providers_from_core[0].clients:
if existing_client.additional_config is not None:
existing_client.additional_config = {
**existing_client.additional_config,
**additional_config,
}
else:
existing_client.additional_config = additional_config
else:
providers_from_core[0].clients = [
ProviderClientConfig(
client_id=&#34;nonguessable-temporary-client-id&#34;,
additional_config=additional_config,
)
]
existing_client.additional_config = {
**(existing_client.additional_config or {}),
**additional_config
}

# filter out other providers from static
static_providers = [
provider
for provider in static_providers
if provider.config.third_party_id == third_party_id
]

if not static_providers and third_party_id == &#34;apple&#34;:
if len(static_providers) == 0 and third_party_id == &#34;apple&#34;:
static_providers.append(
ProviderInput(
config=ProviderConfig(
Expand All @@ -204,27 +201,20 @@ <h1 class="title">Module <code>supertokens_python.recipe.dashboard.api.multitena
&#34;privateKey&#34;: &#34;-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n-----END PRIVATE KEY-----&#34;,
}

if len(static_providers) == 1 and additional_config is not None:
static_providers[0].config.oidc_discovery_endpoint = None
static_providers[0].config.authorization_endpoint = None
static_providers[0].config.token_endpoint = None
static_providers[0].config.user_info_endpoint = None
if static_providers[0].config.clients is not None:
for existing_client in static_providers[0].config.clients:
if existing_client.additional_config is not None:
if len(static_providers) == 1:
# modify additional config if query param is passed
if additional_config is not None:
# we set these to undefined so that these can be computed using the query param that was provided
static_providers[0].config.oidc_discovery_endpoint = None
static_providers[0].config.authorization_endpoint = None
static_providers[0].config.token_endpoint = None
static_providers[0].config.user_info_endpoint = None
if static_providers[0].config.clients is not None:
for existing_client in static_providers[0].config.clients:
existing_client.additional_config = {
**existing_client.additional_config,
**(existing_client.additional_config or {}),
**additional_config,
}
else:
existing_client.additional_config = additional_config
else:
static_providers[0].config.clients = [
ProviderClientConfig(
client_id=&#34;nonguessable-temporary-client-id&#34;,
additional_config=additional_config,
)
]

merged_providers_from_core_and_static = merge_providers_from_core_and_static(
providers_from_core, static_providers, True
Expand All @@ -235,15 +225,14 @@ <h1 class="title">Module <code>supertokens_python.recipe.dashboard.api.multitena

for merged_provider in merged_providers_from_core_and_static:
if merged_provider.config.third_party_id == third_party_id:
if not merged_provider.config.clients:
if merged_provider.config.clients is None or len(merged_provider.config.clients) == 0:
merged_provider.config.clients = [
ProviderClientConfig(
client_id=&#34;nonguessable-temporary-client-id&#34;,
additional_config=(
additional_config if additional_config is not None else None
),
additional_config=additional_config,
)
]

clients: List[ProviderClientConfig] = []
common_provider_config: CommonProviderConfig = CommonProviderConfig(
third_party_id=third_party_id
Expand All @@ -256,7 +245,7 @@ <h1 class="title">Module <code>supertokens_python.recipe.dashboard.api.multitena
if provider.config.third_party_id == third_party_id:
found_correct_config = False

for client in provider.config.clients or []:
for client in (provider.config.clients or []):
try:
provider_instance = await find_and_create_provider_instance(
merged_providers_from_core_and_static,
Expand Down Expand Up @@ -327,7 +316,7 @@ <h1 class="title">Module <code>supertokens_python.recipe.dashboard.api.multitena

break

if additional_config and &#34;privateKey&#34; in additional_config:
if additional_config is not None and &#34;privateKey&#34; in additional_config:
additional_config[&#34;privateKey&#34;] = &#34;&#34;

temp_clients = [
Expand All @@ -341,18 +330,19 @@ <h1 class="title">Module <code>supertokens_python.recipe.dashboard.api.multitena
for client in clients
if client.client_id != &#34;nonguessable-temporary-client-id&#34;
]
if not final_clients:
if len(final_clients) == 0:
final_clients = [
ProviderClientConfig(
client_id=&#34;&#34;,
client_secret=&#34;&#34;,
additional_config=additional_config,
client_type=temp_clients[0].client_type,
force_pkce=temp_clients[0].force_pkce,
scope=temp_clients[0].scope,
force_pkce=temp_clients[0].force_pkce,
additional_config=additional_config,
)
]

# fill in boxy info from boxy instance
if third_party_id.startswith(&#34;boxy-saml&#34;):
boxy_api_key = options.request.get_query_param(&#34;boxyAPIKey&#34;)
if boxy_api_key and final_clients[0].client_id:
Expand Down Expand Up @@ -446,15 +436,21 @@ <h2 class="section-title" id="header-functions">Functions</h2>

additional_config: Optional[Dict[str, Any]] = None

# filter out providers that is not matching thirdPartyId
providers_from_core = [
provider
for provider in providers_from_core
if provider.third_party_id == third_party_id
]

if not providers_from_core:
# if none left, add one to this list so that it takes priority while merging
if len(providers_from_core) == 0:
providers_from_core.append(ProviderConfig(third_party_id=third_party_id))

# At this point, providersFromCore.length === 1

# query param may be passed if we are creating a new third party config, check and update accordingly

if third_party_id in [&#34;okta&#34;, &#34;active-directory&#34;, &#34;boxy-saml&#34;, &#34;google-workspaces&#34;]:
if third_party_id == &#34;okta&#34;:
okta_domain = options.request.get_query_param(&#34;oktaDomain&#34;)
Expand Down Expand Up @@ -484,28 +480,19 @@ <h2 class="section-title" id="header-functions">Functions</h2>

if providers_from_core[0].clients is not None:
for existing_client in providers_from_core[0].clients:
if existing_client.additional_config is not None:
existing_client.additional_config = {
**existing_client.additional_config,
**additional_config,
}
else:
existing_client.additional_config = additional_config
else:
providers_from_core[0].clients = [
ProviderClientConfig(
client_id=&#34;nonguessable-temporary-client-id&#34;,
additional_config=additional_config,
)
]
existing_client.additional_config = {
**(existing_client.additional_config or {}),
**additional_config
}

# filter out other providers from static
static_providers = [
provider
for provider in static_providers
if provider.config.third_party_id == third_party_id
]

if not static_providers and third_party_id == &#34;apple&#34;:
if len(static_providers) == 0 and third_party_id == &#34;apple&#34;:
static_providers.append(
ProviderInput(
config=ProviderConfig(
Expand All @@ -525,27 +512,20 @@ <h2 class="section-title" id="header-functions">Functions</h2>
&#34;privateKey&#34;: &#34;-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n-----END PRIVATE KEY-----&#34;,
}

if len(static_providers) == 1 and additional_config is not None:
static_providers[0].config.oidc_discovery_endpoint = None
static_providers[0].config.authorization_endpoint = None
static_providers[0].config.token_endpoint = None
static_providers[0].config.user_info_endpoint = None
if static_providers[0].config.clients is not None:
for existing_client in static_providers[0].config.clients:
if existing_client.additional_config is not None:
if len(static_providers) == 1:
# modify additional config if query param is passed
if additional_config is not None:
# we set these to undefined so that these can be computed using the query param that was provided
static_providers[0].config.oidc_discovery_endpoint = None
static_providers[0].config.authorization_endpoint = None
static_providers[0].config.token_endpoint = None
static_providers[0].config.user_info_endpoint = None
if static_providers[0].config.clients is not None:
for existing_client in static_providers[0].config.clients:
existing_client.additional_config = {
**existing_client.additional_config,
**(existing_client.additional_config or {}),
**additional_config,
}
else:
existing_client.additional_config = additional_config
else:
static_providers[0].config.clients = [
ProviderClientConfig(
client_id=&#34;nonguessable-temporary-client-id&#34;,
additional_config=additional_config,
)
]

merged_providers_from_core_and_static = merge_providers_from_core_and_static(
providers_from_core, static_providers, True
Expand All @@ -556,15 +536,14 @@ <h2 class="section-title" id="header-functions">Functions</h2>

for merged_provider in merged_providers_from_core_and_static:
if merged_provider.config.third_party_id == third_party_id:
if not merged_provider.config.clients:
if merged_provider.config.clients is None or len(merged_provider.config.clients) == 0:
merged_provider.config.clients = [
ProviderClientConfig(
client_id=&#34;nonguessable-temporary-client-id&#34;,
additional_config=(
additional_config if additional_config is not None else None
),
additional_config=additional_config,
)
]

clients: List[ProviderClientConfig] = []
common_provider_config: CommonProviderConfig = CommonProviderConfig(
third_party_id=third_party_id
Expand All @@ -577,7 +556,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
if provider.config.third_party_id == third_party_id:
found_correct_config = False

for client in provider.config.clients or []:
for client in (provider.config.clients or []):
try:
provider_instance = await find_and_create_provider_instance(
merged_providers_from_core_and_static,
Expand Down Expand Up @@ -648,7 +627,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>

break

if additional_config and &#34;privateKey&#34; in additional_config:
if additional_config is not None and &#34;privateKey&#34; in additional_config:
additional_config[&#34;privateKey&#34;] = &#34;&#34;

temp_clients = [
Expand All @@ -662,18 +641,19 @@ <h2 class="section-title" id="header-functions">Functions</h2>
for client in clients
if client.client_id != &#34;nonguessable-temporary-client-id&#34;
]
if not final_clients:
if len(final_clients) == 0:
final_clients = [
ProviderClientConfig(
client_id=&#34;&#34;,
client_secret=&#34;&#34;,
additional_config=additional_config,
client_type=temp_clients[0].client_type,
force_pkce=temp_clients[0].force_pkce,
scope=temp_clients[0].scope,
force_pkce=temp_clients[0].force_pkce,
additional_config=additional_config,
)
]

# fill in boxy info from boxy instance
if third_party_id.startswith(&#34;boxy-saml&#34;):
boxy_api_key = options.request.get_query_param(&#34;boxyAPIKey&#34;)
if boxy_api_key and final_clients[0].client_id:
Expand Down
Loading

0 comments on commit b59f23e

Please sign in to comment.