-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(portal): Fix edge cases with OIDC discovered in logs (#4777)
Can be reviewed commit by commit.
- Loading branch information
1 parent
90e2033
commit f5b4736
Showing
15 changed files
with
107 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...lib/domain/auth/adapter/directory_sync.ex → .../adapter/openid_connect/directory_sync.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
elixir/apps/domain/lib/domain/auth/adapter/openid_connect/refresh_tokens.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
defmodule Domain.Auth.Adapter.OpenIDConnect.RefreshTokens do | ||
require Logger | ||
|
||
def refresh_access_tokens(name, adapter) do | ||
providers = Domain.Auth.all_providers_pending_token_refresh_by_adapter!(name) | ||
Logger.debug("Refreshing access tokens for #{length(providers)} #{name} providers") | ||
|
||
Enum.each(providers, fn provider -> | ||
Logger.metadata( | ||
provider_id: provider.id, | ||
account_id: provider.account_id, | ||
adapter: name | ||
) | ||
|
||
Logger.debug("Refreshing access token") | ||
|
||
fn -> adapter.refresh_access_token(provider) end | ||
|> with_sync_retries() | ||
|> case do | ||
{:ok, _provider} -> | ||
Logger.debug("Finished refreshing access token") | ||
|
||
{:error, reason} -> | ||
Logger.error("Failed refreshing access token", | ||
reason: inspect(reason) | ||
) | ||
end | ||
end) | ||
end | ||
|
||
defp with_sync_retries(cb, retries_left \\ 3, retry_timeout \\ 100) do | ||
case cb.() do | ||
{:ok, result} -> | ||
{:ok, result} | ||
|
||
{:error, _reason} when retries_left > 0 -> | ||
Process.sleep(retry_timeout) | ||
with_sync_retries(cb, retries_left - 1, retry_timeout) | ||
|
||
{:error, reason} -> | ||
{:error, reason} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters