Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Higress网关集成安全认证,基于全局配置实现对接自定义鉴权服务 #207

Open
wangdechong opened this issue Feb 21, 2023 · 4 comments

Comments

@wangdechong
Copy link

Why do you need it?

Is your feature request related to a problem? Please describe in details

Higress网关集成自定义鉴权服务,方便在网关入口处完成鉴权,避免每个后端服务都接入鉴权服务。接入安全认证。

How could it be?

A clear and concise description of what you want to happen. You can explain more about input of the feature, and output of it.
Higress对接自建的中心化鉴权服务完成鉴权操作,Higress支持配置鉴权API的方式、或者其他便捷配置。
鉴权服务返回HTTP状态码为200,表明Token合法且Token有权限访问该后端资源,网关继续将原始业务请求转发给受保护的后端服务,收到业务响应后再次转发给客户端。

@johnlanni
Copy link
Collaborator

可以基于ingress annotaion实现到istio envoyfilter的转换,自定义鉴权+路由白名单的envoyfilter示例:

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: ext-authz-test
spec:
  configPatches:
  - applyTo: HTTP_FILTER
    match:
      context: GATEWAY
      listener:
        filterChain:
          filter:
            name: envoy.http_connection_manager
            subFilter:
              name: envoy.filters.http.cors
    patch:
      operation: INSERT_AFTER
      value:
        name: envoy.filters.http.ext_authz
        typed_config:
          '@type': type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz
          filter_enabled_metadata:
            filter: envoy.filters.http.rbac
            path:
            - key: shadow_effective_policy_id
            value:
              string_match:
                exact: ext-authz-test
          httpService:
            authorizationRequest:
              allowedHeaders:
                patterns:
                - exact: x-token
            authorizationResponse:
              allowedUpstreamHeaders:
                patterns:
                - exact: x-user-id
            pathPrefix: /check
            serverUri:
              cluster: outbound|8080||auth-server.default.svc.cluster.local
              timeout: 10s
              uri: auth-server.default.svc.cluster.local
          withRequestBody:
            maxRequestBytes: 1024000
  - applyTo: HTTP_FILTER
    match:
      context: GATEWAY
      listener:
        filterChain:
          filter:
            name: envoy.http_connection_manager
            subFilter:
              name: envoy.filters.http.ext_authz
    patch:
      operation: INSERT_BEFORE
      value:
        name: envoy.filters.http.rbac
        typed_config:
          '@type': type.googleapis.com/envoy.extensions.filters.http.rbac.v3.RBAC
          shadow_rules:
            action: ALLOW
            policies:
              ext-authz-test:
                permissions:
                - or_rules:
                    rules:
                    - and_rules:
                        rules:
                        - url_path:
                            path:
                              ignore_case: false
                              prefix: /test
                principals:
                - any: true

参考配置字段:
ext-authz filter:https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/ext_authz/v3/ext_authz.proto#envoy-v3-api-msg-extensions-filters-http-ext-authz-v3-extauthz
rbac filter:https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/rbac/v3/rbac.proto#envoy-v3-api-msg-config-rbac-v3-permission

@johnlanni johnlanni changed the title Higress网关集成安全认证,实现自定义鉴权服务 Higress网关集成安全认证,基于Ingress Annotation实现对接自定义鉴权服务 Feb 21, 2023
@zhangcly
Copy link
Contributor

可以给我

@johnlanni johnlanni removed the help wanted Extra attention is needed label Feb 22, 2023
zhangcly added a commit to zhangcly/higress that referenced this issue Mar 30, 2023
zhangcly added a commit to zhangcly/higress that referenced this issue Mar 31, 2023
@johnlanni johnlanni added the help wanted Extra attention is needed label Aug 31, 2023
@johnlanni johnlanni changed the title Higress网关集成安全认证,基于Ingress Annotation实现对接自定义鉴权服务 Higress网关集成安全认证,基于全局配置实现对接自定义鉴权服务 Aug 31, 2023
@johnlanni
Copy link
Collaborator

#263

基于这个PR下的讨论,使用 Ingress 注解实现该功能,无法解决 rbac 下的路径匹配跟 ingress 路径匹配的对应关系,可能导致 ingress 下通过注解配置该功能,导致对其他 ingress 生效。
通过实现 rbac match 路由名称,可以解决这一问题,但涉及 envoy 引擎侧较多改造。
目前更倾向于在全局配置中进行自定义鉴权规则配置,包括配置对哪些路径匹配生效。全局配置的实现可以参考这篇blog:https://higress.io/zh-cn/blog/configmap

感谢 @zhangcly#263 上完成的部分 envoyfilter 转换能力,是可以复用的,但目前他没有时间继续做这块工作,欢迎其他有兴趣的同学在他的基础上,继续完成这块工作

@Lvnszn
Copy link

Lvnszn commented Aug 31, 2023

mark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

5 participants