接口 ProtocolAuthService<R>

    • 方法概要

      所有方法 实例方法 抽象方法 
      修饰符和类型 方法 说明
      boolean enableAuth​(Secured secured)
      Judgement whether enable auth feature according to secured information.
      void initialize()
      Init protocol auth service.
      com.alibaba.nacos.plugin.auth.api.IdentityContext parseIdentity​(R request)
      Parse identity context from protocol request.
      com.alibaba.nacos.plugin.auth.api.Resource parseResource​(R request, Secured secured)
      Parse resource from protocol request and secured annotation.
      boolean validateAuthority​(com.alibaba.nacos.plugin.auth.api.IdentityContext identityContext, com.alibaba.nacos.plugin.auth.api.Permission permission)
      Validate identity whether had permission for the resource and action.
      boolean validateIdentity​(com.alibaba.nacos.plugin.auth.api.IdentityContext identityContext, com.alibaba.nacos.plugin.auth.api.Resource resource)
      Validate identity whether is legal.
    • 方法详细资料

      • initialize

        void initialize()
        Init protocol auth service.
      • enableAuth

        boolean enableAuth​(Secured secured)
        Judgement whether enable auth feature according to secured information.

        configuration authEnabled in AuthConfigs is the main switch. If authEnabled is false, this method and other follow methods should not be called. This method is only for plugin to judge whether auth this Secured. For example, plugins can only auth for write action or only for naming type request.

        参数:
        secured - secured information
        返回:
        true if enable auth, otherwise false
      • parseResource

        com.alibaba.nacos.plugin.auth.api.Resource parseResource​(R request,
                                                                 Secured secured)
        Parse resource from protocol request and secured annotation.
        参数:
        request - protocol request
        secured - api secured annotation
        返回:
        resource
      • parseIdentity

        com.alibaba.nacos.plugin.auth.api.IdentityContext parseIdentity​(R request)
        Parse identity context from protocol request.
        参数:
        request - protocol request
        返回:
        identity context
      • validateIdentity

        boolean validateIdentity​(com.alibaba.nacos.plugin.auth.api.IdentityContext identityContext,
                                 com.alibaba.nacos.plugin.auth.api.Resource resource)
                          throws com.alibaba.nacos.plugin.auth.exception.AccessException
        Validate identity whether is legal.
        参数:
        identityContext - identity context
        resource - resource
        返回:
        true if legal, otherwise false
        抛出:
        com.alibaba.nacos.plugin.auth.exception.AccessException - exception during validating
      • validateAuthority

        boolean validateAuthority​(com.alibaba.nacos.plugin.auth.api.IdentityContext identityContext,
                                  com.alibaba.nacos.plugin.auth.api.Permission permission)
                           throws com.alibaba.nacos.plugin.auth.exception.AccessException
        Validate identity whether had permission for the resource and action.
        参数:
        identityContext - identity context
        permission - permission include resource and action
        返回:
        true if legal, otherwise false
        抛出:
        com.alibaba.nacos.plugin.auth.exception.AccessException - exception during validating