Granted authorities from CurrentAuthentication returns unexpected results

Hello,

Jmix version: 2.1.1
Jmix Studio plugin version: 2.1.NIGHTLY1262-232
IntelliJ version: IntelliJ IDEA 2023.2.5 (Community Edition)

I’m wondering if I’m doing something incorrectly. I’ve extended LoginViewSupport to allow for a conditional redirect, which only navigates as usual if the user has the system-provided FullAccessRole set. Otherwise, it navigates to a root screen view. I’ve gotten this to work, but the reference to the FullAccessRole.CODE property isn’t really useful here, as it appears that the string values returned from

currentAuthentication.getAuthentication().getAuthorities()

include a ROLE_ prefix, which seems really odd. I figured I’d make sure I’m not doing anything incorrectly, as it seems like I should be getting the direct CODE property returned.

I look forward to hearing back,

Adam

Hi,

You’re not doing something wrong. Since v2.1 improve in Authentication object structure is introduced. See GitHub issue for more detail.

The ROLE_ prefix is added intentionally:

Jmix resource roles are represented as strings consisting of the ROLE_ prefix and resource role code, e.g. ROLE_system-full-access .

Regards,
Gleb