Skip to content

feat: Enable configuration of the OpenIdmetadata's refresh interval #4877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ceciliaavila
Copy link
Collaborator

#minor

Description

This PR adds the tokenRefreshInterval property to the ConnectorClientOptions interface to set up the interval in the bot's configuration. This value is used in OpenIdMetadata's getKey method to retrieve the key from the cache, or to make a new request.

The interval should be configured in the following way:

const botFrameworkAuthentication = new ConfigurationBotFrameworkAuthentication(
    process.env,
    undefined,
    undefined,
    undefined,
    { tokenRefreshInterval: 1 } // Set the token refresh interval to 1 hour.
);

const adapter = new CloudAdapter(botFrameworkAuthentication);

Considerations:

  • If tokenRefreshInterval is not set, it defaults to 24 hours (as it was originally).
  • If tokenRefreshInterval is set to 0, it refreshes the token for each request.
  • If tokenRefreshInterval is set to a value, e.g. 1, it refreshes the token after an hour.

Specific Changes

  • Updated ConnectorClientOptions interface to include the tokenRefreshInterval property.
  • Updated OpenIdMetadata class to receive the interval in the constructor and use it in the getKey method.
  • Updated JwtTokenExtractor to pass the value of the interval to the OpenIdMetadata class.
  • Updated ParameterizedBotFrameworkAuthentication to pass the value from the options to the JwtTokenExtractor instances.
  • Added 2 new unit tests in openIdMetadata.test.

Testing

These images show the configuration tested with a bot and the new tests passing.
image
image

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.

1 participant