use of io.micronaut.security.annotation.Secured in project akhq by tchiotludo.
the class TopicController method data.
@Secured(Role.ROLE_TOPIC_DATA_READ)
@Get("api/{cluster}/topic/{topicName}/data")
@Operation(tags = { "topic data" }, summary = "Read datas from a topic")
public ResultNextList<Record> data(HttpRequest<?> request, String cluster, String topicName, Optional<String> after, Optional<Integer> partition, Optional<RecordRepository.Options.Sort> sort, Optional<String> timestamp, Optional<String> searchByKey, Optional<String> searchByValue, Optional<String> searchByHeaderKey, Optional<String> searchByHeaderValue) throws ExecutionException, InterruptedException {
Topic topic = this.topicRepository.findByName(cluster, topicName);
RecordRepository.Options options = dataSearchOptions(cluster, topicName, after, partition, sort, timestamp, searchByKey, searchByValue, searchByHeaderKey, searchByHeaderValue);
URIBuilder uri = URIBuilder.fromURI(request.getUri());
List<Record> data = this.recordRepository.consume(cluster, options);
return TopicDataResultNextList.of(data, options.after(data, uri), (options.getPartition() == null ? topic.getSize() : topic.getSize(options.getPartition())), this.isAllowed(Role.ROLE_TOPIC_DATA_DELETE) && topic.canDeleteRecords(cluster, configRepository));
}
use of io.micronaut.security.annotation.Secured 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