Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #11001
Closed
Open
Issue created Nov 30, 2021 by Administrator@rootContributor

[REQ][csharp-netcore] ApiTokenFactory on configuration to make hooking in auto refreshing JWT Tokens much easier

Created by: RubberChickenParadise

Is your feature request related to a problem? Please describe.

Currently there is no good way to change out the Bearer access token after initialization of the Configuration when using Microsoft.Extensions.DependentyInjection with a singleton Configuration object.

Describe the solution you'd like

After looking at the code, adding an Access Token producer Func which defaults to returning the Access Token property would enable end users to easily customize the Access Token producer with advanced logic, such as checking the expiration of the JWT then calling the Security Token Service to silently refresh the JWT.

Describe alternatives you've considered

An alternative would be to have the Configuration be a Scoped service but even that leads to issues if used in a long running scope (think WinForms desktop app)

A transient scope with a configuration constructor method to handle refreshing the token would be another possibility but that has the additional complication of requiring all the API classes be registered as transient as well, however that has the initialization overhead every time an instance of the API classes is requested.

Additional context

Just adding the Func GetAccessToken {get;set;} => ()=> AccessToken; then calling GetAccessToken instead of the property access would enable a much more configurable configuration object with minimal changes.

Assignee
Assign to
Time tracking