Skip to content

Simplify boilerplate configuration for web and api applicaitons #197

Open
@bdemers

Description

Describe the feature request?

The default configuration needed to initialize an API (or web) application can be reduced/simplified for basic use cases.

  • OktaWebApiOptions should allow the caller to set the Issuer instead of requiring both the OktaDomain and the AuthorizationServerId (this could be done backward compatible and not affect existing users).

NOTE: Okta's API quick start guides will be using the Issuer instead of the Okta Domain.

  • Configuration parameters should be parsed from known configuration keys Okta:OktaDomain, Okta:AuthorizationServerId, Okta:Issuer, etç. automatically when possible.

  • Consider adding a util method to configure the AuthenticationOptions as a single line.

For example, the current quick start looks similar to this:

services.AddAuthentication(options =>
{
    options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
    options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
    options.DefaultSignInScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddOktaWebApi(new OktaWebApiOptions(Configuration)
{
    OktaDomain = Configuration["Okta:OktaDomain"]
});

services.AddAuthorization();

This requires the developer to understand a number of things to configure the framework correctly.

Ideally, we could do something like:

services.AddAuthentication(options =>
{
    Okta.AddAuthentication(options); // some sort of helper method
})
.AddOktaWebApi(new OktaWebApiOptions(Configuration)); // add a `OktaWebApiOptions` constructor to parse the config

services.AddAuthorization();

If possible... we could reduce this even further to something like:

public void ConfigureServices(IServiceCollection services)
{
    Okta.ConfigureApiServices(services, new OktaWebApiOptions(Configuration));
}

This last option may make it too "magical" and more difficult to figure out the touchpoints when a developer needs to configure other authentication/authorization options?

NOTE: Take this all with a grain of salt 🧂, as I'm not sure what the equivalent idiomatic csharp would be.

.NET Version

💯

Provide a documentation link if applicable

No response

Additional Information?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions