Hi,
when navigating to the api /ui page we want to be able for users to enter their api key.
That should be passed in the header as x-api-key when submitting (testing) any api call
I tried with the OpenApiFeature but it doesnt effect this page
Plugins.Add(new OpenApiFeature()
{
DisableSwaggerUI = false,
ApiDeclarationFilter = api =>
{
api.SecurityDefinitions.Add(
"apiKey", new OpenApiSecuritySchema {
Type = "apiKey",
Name = "x-api-key", // Use "x-api-key" as the header name
In = "header",
Description = "API Key Authentication"
});
},
The registered Auth Options are supported in the Integrated Sign In dialog where it’s added to the clients BearerToken, but it doesn’t support custom Auth configurations.
Still the same problem when only having JwtAuthProvider
Console errors
The script from “http://localhost:58999/auth?callback=loadAuth&jsconfig=eccn” was loaded even though its MIME type (“application/json”) is not a valid JavaScript MIME type.
ui
asm.js type error: Asm.js optimizer disabled because debugger is active es-module-shims.js
breakpoints.change
Proxy { <target>: {…}, <handler>: {…} }
Proxy { <target>: {…}, <handler>: {…} }
app.mjs:63:49
routes.start() op <empty string> core.mjs:42:9
nav
Object { }
It’s because you’re using JwtAuthProviderReader instead of JwtAuthProvider which defines the FormLayout the SignIn Vue component should use to render the form.
So you need to either change it to use JwtAuthProvider:
var authFeature = new AuthFeature(() => new AspnetMembershipAuthSession(), new IAuthProvider[]
{
new JwtAuthProvider(AppSettings)
{
RequireSecureConnection = false,
PopulateSessionFilter = AspnetMembershipAuthSession.TokenToSession,
}
});
Or to use JwtAuthProviderReader you need to explicitly specify the FormLayout it should use with:
var authFeature = new AuthFeature(() => new AspnetMembershipAuthSession(), new IAuthProvider[]
{
new JwtAuthProviderReader(AppSettings)
{
RequireSecureConnection = false,
PopulateSessionFilter = AspnetMembershipAuthSession.TokenToSession,
FormLayout = new() {
new InputInfo(nameof(IHasBearerToken.BearerToken), ServiceStack.Html.Input.Types.Textarea) {
Label = "JWT",
Placeholder = "JWT Bearer Token",
Required = true,
},
}
}
});