Skip to content

Conversation

parkerduckworth
Copy link
Member

A setInterval is used to run a background OIDC token refresh, but ends up blocking a script from exiting due to the interval never being cleared.

This PR adds two changes to surmount this issue:

  1. An explicit client.oidcAuth?.stopTokenRefresh() method which should be used whenever a script is expected to exit, or it is otherwise determined that token refresh is no longer needed
  2. A silentRefresh?: boolean argument to each of the OIDC credential inputs, including AuthClientCredentials, AuthUserPasswordCredentials, and AuthAccessTokenCredentials. This currently defaults to true if not set, as this is likely the expected behavior for most users.

Closes #30

@parkerduckworth parkerduckworth requested a review from dirkkul March 31, 2023 22:03
basedOnProperties: this.basedOnProperties,
});

pollForCompletion = (id: any): Promise<Classification> => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does classifcation have its own timeout check?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been in the client for a long time. This is the implementation of an option which tells the client to block until classification is complete.

this.clientSecret = creds.clientSecret;
this.scopes = creds.scopes;
// Silent token refresh by default
if (creds.silentRefresh === undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to be sure:
This means that this parameter is not required and this is not a breaking change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, if silentRefresh is not provided, the behavior is unchanged, in that silent refresh will run in the background

@parkerduckworth parkerduckworth merged commit 976666e into main Apr 4, 2023
@parkerduckworth parkerduckworth deleted the fix/oidc-background-refresh branch April 4, 2023 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Script not exiting when using AuthUserPasswordCredentials
2 participants