scalecube-services icon indicating copy to clipboard operation
scalecube-services copied to clipboard

Enhance/Refactor ServiceMethodInvoker.mapPrincipal()

Open artem-v opened this issue 5 months ago • 0 comments

  • Even if method is not secured - still apply principalMapper.map(context) (if mapper is present)

  • Simplify

    return Mono.defer(() -> principalMapper.map(context))
        .switchIfEmpty(Mono.just(context.principal()));

to

return Mono.defer(() -> principalMapper.map(context))

Let client worry about what to return in the mapper. Don't make scalecube to "fallback" something if it was null.

  • Refactor io.scalecube.services.RequestContext#toString

  • Fix bug in audit log:

              if (!context.hasPrincipal()) {
                LOGGER.warn(
                    "Insufficient permissions for secured method ({}) -- "
                        + "request context ({}) does not have principal",
                    context,
                    context.methodInfo());
                throw new ForbiddenException("Insufficient permissions");
              }

artem-v avatar Jun 18 '25 11:06 artem-v