use of io.micronaut.security.utils.SecurityService in project akhq by tchiotludo.
the class ConnectRepository method getConnectFilterRegex.
private Optional<List<String>> getConnectFilterRegex() {
List<String> connectFilterRegex = new ArrayList<>();
if (applicationContext.containsBean(SecurityService.class)) {
SecurityService securityService = applicationContext.getBean(SecurityService.class);
Optional<Authentication> authentication = securityService.getAuthentication();
if (authentication.isPresent()) {
Authentication auth = authentication.get();
connectFilterRegex.addAll(getConnectFilterRegexFromAttributes(auth.getAttributes()));
}
}
// get Connect filter regex for default groups
connectFilterRegex.addAll(getConnectFilterRegexFromAttributes(defaultGroupUtils.getDefaultAttributes()));
return Optional.of(connectFilterRegex);
}
use of io.micronaut.security.utils.SecurityService in project akhq by tchiotludo.
the class TopicRepository method getTopicFilterRegex.
private Optional<List<String>> getTopicFilterRegex() {
List<String> topicFilterRegex = new ArrayList<>();
if (applicationContext.containsBean(SecurityService.class)) {
SecurityService securityService = applicationContext.getBean(SecurityService.class);
Optional<Authentication> authentication = securityService.getAuthentication();
if (authentication.isPresent()) {
Authentication auth = authentication.get();
topicFilterRegex.addAll(getTopicFilterRegexFromAttributes(auth.getAttributes()));
}
}
// get topic filter regex for default groups
topicFilterRegex.addAll(getTopicFilterRegexFromAttributes(defaultGroupUtils.getDefaultAttributes()));
return Optional.of(topicFilterRegex);
}
use of io.micronaut.security.utils.SecurityService in project akhq by tchiotludo.
the class ConsumerGroupRepository method getConsumerGroupFilterRegex.
private Optional<List<String>> getConsumerGroupFilterRegex() {
List<String> consumerGroupFilterRegex = new ArrayList<>();
if (applicationContext.containsBean(SecurityService.class)) {
SecurityService securityService = applicationContext.getBean(SecurityService.class);
Optional<Authentication> authentication = securityService.getAuthentication();
if (authentication.isPresent()) {
Authentication auth = authentication.get();
consumerGroupFilterRegex.addAll(getConsumerGroupFilterRegexFromAttributes(auth.getAttributes()));
}
}
// get consumer group filter regex for default groups
consumerGroupFilterRegex.addAll(getConsumerGroupFilterRegexFromAttributes(defaultGroupUtils.getDefaultAttributes()));
return Optional.of(consumerGroupFilterRegex);
}
use of io.micronaut.security.utils.SecurityService in project akhq by tchiotludo.
the class AkhqController method users.
@Secured(SecurityRule.IS_ANONYMOUS)
@Get("api/me")
@Operation(tags = { "AKHQ" }, summary = "Get current user")
public AuthUser users() {
AuthUser authUser = new AuthUser();
if (applicationContext.containsBean(SecurityService.class)) {
SecurityService securityService = applicationContext.getBean(SecurityService.class);
securityService.getAuthentication().ifPresent(authentication -> {
authUser.logged = true;
authUser.username = authentication.getName();
});
}
authUser.roles = this.getRights();
return authUser;
}
Aggregations