FlowUI: public REST (jmix.rest.anonymous-url-patterns) not working

I’ve got some URLs defined in the jmix.rest.anonymous-url-patterns property. It seems that they don’t work anymore in FlowUI. I’m always redirected to the login page.

Also a request to my custom spring RestController I have redirects now to the login page.

Hi,

Could you please provide more details about the case when jmix.rest.anonymous-url-patterns doesn’t work?

As for custom controller, what authentication does it expect? I guess you need to add a security configuration for this controller, e.g.:

@Configuration
public class MyRestSecurityConfiguration {

    @Order(JmixOrder.HIGHEST_PRECEDENCE + 100)
    @Bean
    public SecurityFilterChain mySecurityFilterChain(HttpSecurity http) throws Exception {
        http.mvcMatcher("/hello/**")
                .authorizeHttpRequests(authorize -> {
                    authorize.anyRequest().permitAll();
                });
        return http.build();
    }
}
1 Like

Hi @gorbunkov , thanks for your response. I’m late, because it kind of solved itself and didn’t appear again. At that time it wasn’t just an issue on my local machine (where I could reproduce it back then) but also on the servers. Interestingly I sometimes encountered a bug, where the authentication was suddenly set to a different user. (Jmix 1.4.4 - FlowUI) Could have been a problem with the remember-me auth or something. Can’t really reproduce it now, but I think those issues where related.

Hi Maxim,

anonymous-url-patterns are not working for me in JMIX 2.0…

my pattern:
jmix.rest.anonymous-enabled = true
jmix.rest.anonymous-url-patterns=/qrcode,/qrcode/[ASTERIX],/rest/docs/*

swagger is working, for qrcode I tried different settings… none is working.

My controller class:

@RestController
@RequestMapping("/qrcode")
public class QRLoginBean {
@GetMapping("/getqrcode")
public ResponseEntity myqrcode(
@RequestParam String code
) {
return ResponseEntity
.status(HttpStatus.OK)
.header(HttpHeaders.CACHE_CONTROL, “max-age=31536000”)
.body(code);
}
}

my postman call: http://localhost:8080/qrcode/getqrcode/myqrcode?code=somecode

I also tried to use your example with http.mvcMatcher … mvcMatcher and anyRequest cannot be resolved.

Any idea?
KR
Roland

I’ve just tried and jmix.rest.anonymous-url-patterns seems to work fine.

I used your controller and the following property:

jmix.rest.anonymous-url-patterns=/qrcode/**

Probably the problem is that you use a wrong URL, it should be just

http://localhost:8080/qrcode/getqrcode?code=somecode

You’ve added the /myqrcode that should not be there.

1 Like

thx… I must have been blind… and there was also another typo…
now it works like expected