I have a problem with the UI (hosted at /ui
) that I cannot immediately figure out.
Problem
We are using the AuthFeature
, with a bunch of providers, as such:
appHost.Plugins.Add(new AuthFeature(() => new AuthUserSession(),
new IAuthProvider[]
{
AuthenticationProviders.CreateJwtProviderForSigningAndValidation(settings),
AuthenticationProviders.CreateApiKeyProviderForValidation(
container.LazyResolve<IApiKeyApplication>()),
AuthenticationProviders.CreateHmacProviderForValidation(settings),
AuthenticationProviders.CreateCredentialsProviderForAuthentication(
container.LazyResolve<IUserCredentialsApplication>())
})
{
SaveUserNamesInLowerCase = true,
ValidateUniqueUserNames = true,
ValidateUniqueEmails = true,
IsValidUsernameFn = username => Validations.EmailAddress.Matches(username),
IncludeRolesInAuthenticateResponse = true,
IncludeAssignRoleServices = false,
IncludeRegistrationService = false,
IncludeDefaultLogin = false
});
and thus we get the built in “Login UI”, (at /ui
) which is great.
Now, if a developer selects the “Credentials” tab and fills out the form, the login attempt does succeed,
The format of those roles (in green) is how we define them
but, if we try to use any of the APIs from the left pane, they are called without including our JWT bearer token in the request. (Fiddler confirms that)
Workaround
However, we can make the whole thing work if we use the Authenticate
request (at /ui/Authenticate
).
Then get a JSON response containing a bearerToken
that we can then copy and paste into the “JWT” tab of the “Login UI” on the “JWT” tab (at /ui
).
Then calling any APIs from the left pane now includes the JWT in the request. (Fiddler confirms this).
Question
Is there something I can do to make it work through the “Credentials” tab (at /ui
)? or what other options do I have? the workaround is not obvious and a PITA to get working for the user.