You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/11/21 10:12:30 UTC
[GitHub] [dubbo-go-pixiu] baerwang opened a new pull request #303: feat:auth filter
baerwang opened a new pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303
<!-- Thanks for sending a pull request!
-->
**What this PR does**:
**Which issue(s) this PR fixes**:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
_If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
-->
Fixes #
**Special notes for your reviewer**:
**Does this PR introduce a user-facing change?**:
<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->
```release-note
NONE
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] codecov-commenter commented on pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#issuecomment-976194931
# [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#303](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (85af2ed) into [develop](https://codecov.io/gh/apache/dubbo-go-pixiu/commit/d1930df3e910c5f948380c703fbbce4f49490d2d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d1930df) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## develop #303 +/- ##
========================================
Coverage 33.93% 33.93%
========================================
Files 61 61
Lines 3165 3165
========================================
Hits 1074 1074
Misses 1979 1979
Partials 112 112
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [d1930df...85af2ed](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] codecov-commenter edited a comment on pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#issuecomment-976194931
# [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#303](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (cb16ad0) into [develop](https://codecov.io/gh/apache/dubbo-go-pixiu/commit/11535b0fd11ac4d5f676148dc0ad8e64e730757e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (11535b0) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## develop #303 +/- ##
========================================
Coverage 36.14% 36.14%
========================================
Files 55 55
Lines 3295 3295
========================================
Hits 1191 1191
Misses 1985 1985
Partials 119 119
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [11535b0...cb16ad0](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] codecov-commenter edited a comment on pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#issuecomment-976194931
# [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#303](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (fcc47bd) into [develop](https://codecov.io/gh/apache/dubbo-go-pixiu/commit/11535b0fd11ac4d5f676148dc0ad8e64e730757e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (11535b0) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## develop #303 +/- ##
========================================
Coverage 36.14% 36.14%
========================================
Files 55 55
Lines 3295 3295
========================================
Hits 1191 1191
Misses 1985 1985
Partials 119 119
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [11535b0...fcc47bd](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] ztelur commented on a change in pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
ztelur commented on a change in pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#discussion_r758055714
##########
File path: pkg/filter/auth/jwt/jwt.go
##########
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jwt
+
+import (
+ "encoding/json"
+ "fmt"
+ stdHttp "net/http"
+ "strings"
+ "time"
+)
+
+import (
+ "github.com/MicahParks/keyfunc"
+ jwt4 "github.com/golang-jwt/jwt/v4"
+)
+
+import (
+ "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
+ "github.com/apache/dubbo-go-pixiu/pkg/common/extension/filter"
+ "github.com/apache/dubbo-go-pixiu/pkg/context/http"
+ "github.com/apache/dubbo-go-pixiu/pkg/logger"
+)
+
+const (
+ Kind = constant.HTTPAuthJwtFilter
+)
+
+func init() {
+ filter.RegisterHttpFilter(&Plugin{})
+}
+
+type (
+ // Plugin is http filter plugin.
+ Plugin struct {
+ }
+
+ // Filter is http filter instance
+ Filter struct {
+ cfg *Config
+ errMsg []byte
+ providerJwks map[string]Provider
+ }
+
+ // Config describe the config of Filter
+ Config struct {
+ ErrMsg string `yaml:"err_msg" json:"err_msg" mapstructure:"err_msg"`
+ Rules []Rules `yaml:"rules" json:"rules" mapstructure:"rules"`
+ Providers []Providers `yaml:"providers" json:"providers" mapstructure:"providers"`
+ }
+)
+
+func (p Plugin) Kind() string {
+ return Kind
+}
+
+func (p *Plugin) CreateFilter() (filter.HttpFilter, error) {
+ return &Filter{cfg: &Config{}, providerJwks: map[string]Provider{}}, nil
+}
+
+func (f *Filter) PrepareFilterChain(ctx *http.HttpContext) error {
+ ctx.AppendFilterFunc(f.Handle)
+ return nil
+}
+
+func (f *Filter) Handle(ctx *http.HttpContext) {
+
+ path := ctx.Request.RequestURI
+
+ router := false
+
+ for _, rule := range f.cfg.Rules {
+ if strings.HasPrefix(path, rule.Match.Prefix) {
+ router = true
+ if f.validAny(rule, ctx) || f.validAll(rule, ctx) {
+ ctx.Next()
+ break
+ }
+ }
+ }
+
+ if router {
Review comment:
看着 strings.HasPrefix(path, rule.Match.Prefix) 后不就直接将 router 设置为true了嘛,并不是存在并且没通过valid。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] AlexStocks commented on a change in pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#discussion_r753845702
##########
File path: pkg/filter/auth/jwt/config.go
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jwt
+
+import "github.com/MicahParks/keyfunc"
+
+type (
+ // FromHeaders Get the token from a field in the header,default Authorization: Bearer <token>
+ FromHeaders struct {
+ Name string `yaml:"name" json:"name" mapstructure:"name"`
+ ValuePrefix string `yaml:"value_prefix" json:"value_prefix" mapstructure:"value_prefix"`
+ }
+
+ Rules struct {
+ Match Match `yaml:"match" json:"match" mapstructure:"match"`
+ Requires Requires `yaml:"requires" json:"requires" mapstructure:"requires"`
+ }
+
+ Match struct {
+ Prefix string `yaml:"prefix" json:"prefix" mapstructure:"prefix"`
+ }
+
+ Requires struct {
+ RequiresAny Requirement `yaml:"requires_any" json:"requires_any" mapstructure:"requires_any"`
+ RequiresAll []Requirement `yaml:"requires_all" json:"requires_all" mapstructure:"requires_all"`
+ }
+
+ Requirement struct {
+ ProviderName string `yaml:"provider_name" json:"provider_name" mapstructure:"provider_name"`
+ }
+
+ Providers struct {
+ Name string `yaml:"name" json:"name" mapstructure:"name"`
+ ForwardPayloadHeader string `yaml:"forward_payload_header" json:"forward_payload_header" mapstructure:"forward_payload_header"`
+ FromHeaders FromHeaders `yaml:"from_headers" json:"from_headers" mapstructure:"from_headers"`
+ Issuer string `yaml:"issuer" json:"issuer" mapstructure:"issuer"`
+ Local *Local `yaml:"local_jwks" json:"local_jwks" mapstructure:"local_jwks"`
+ Remote *Remote `yaml:"remote_jwks" json:"remote_jwks" mapstructure:"remote_jwks"`
+ }
+
+ Local struct {
+ InlineString string `yaml:"inline_string" json:"inline_string" mapstructure:"inline_string"`
+ }
+
+ Remote struct {
+ HttpUri HttpUri `yaml:"http_uri" json:"http_uri" mapstructure:"http_uri"`
+ }
+
+ HttpUri struct {
Review comment:
HttpURI
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] ztelur commented on a change in pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
ztelur commented on a change in pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#discussion_r757832311
##########
File path: pkg/filter/auth/jwt/jwt.go
##########
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jwt
+
+import (
+ "encoding/json"
+ "fmt"
+ stdHttp "net/http"
+ "strings"
+ "time"
+)
+
+import (
+ "github.com/MicahParks/keyfunc"
+ jwt4 "github.com/golang-jwt/jwt/v4"
+)
+
+import (
+ "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
+ "github.com/apache/dubbo-go-pixiu/pkg/common/extension/filter"
+ "github.com/apache/dubbo-go-pixiu/pkg/context/http"
+ "github.com/apache/dubbo-go-pixiu/pkg/logger"
+)
+
+const (
+ Kind = constant.HTTPAuthJwtFilter
+)
+
+func init() {
+ filter.RegisterHttpFilter(&Plugin{})
+}
+
+type (
+ // Plugin is http filter plugin.
+ Plugin struct {
+ }
+
+ // Filter is http filter instance
+ Filter struct {
+ cfg *Config
+ errMsg []byte
+ providerJwks map[string]Provider
+ }
+
+ // Config describe the config of Filter
+ Config struct {
+ ErrMsg string `yaml:"err_msg" json:"err_msg" mapstructure:"err_msg"`
+ Rules []Rules `yaml:"rules" json:"rules" mapstructure:"rules"`
+ Providers []Providers `yaml:"providers" json:"providers" mapstructure:"providers"`
+ }
+)
+
+func (p Plugin) Kind() string {
+ return Kind
+}
+
+func (p *Plugin) CreateFilter() (filter.HttpFilter, error) {
+ return &Filter{cfg: &Config{}, providerJwks: map[string]Provider{}}, nil
+}
+
+func (f *Filter) PrepareFilterChain(ctx *http.HttpContext) error {
+ ctx.AppendFilterFunc(f.Handle)
+ return nil
+}
+
+func (f *Filter) Handle(ctx *http.HttpContext) {
+
+ path := ctx.Request.RequestURI
+
+ router := false
+
+ for _, rule := range f.cfg.Rules {
+ if strings.HasPrefix(path, rule.Match.Prefix) {
+ router = true
+ if f.validAny(rule, ctx) || f.validAll(rule, ctx) {
+ ctx.Next()
+ break
+ }
+ }
+ }
+
+ if router {
Review comment:
为什么router为true就返回401,不是还需要判断validAny和validAll嘛
##########
File path: pkg/filter/auth/jwt/jwt.go
##########
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jwt
+
+import (
+ "encoding/json"
+ "fmt"
+ stdHttp "net/http"
+ "strings"
+ "time"
+)
+
+import (
+ "github.com/MicahParks/keyfunc"
+ jwt4 "github.com/golang-jwt/jwt/v4"
+)
+
+import (
+ "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
+ "github.com/apache/dubbo-go-pixiu/pkg/common/extension/filter"
+ "github.com/apache/dubbo-go-pixiu/pkg/context/http"
+ "github.com/apache/dubbo-go-pixiu/pkg/logger"
+)
+
+const (
+ Kind = constant.HTTPAuthJwtFilter
+)
+
+func init() {
+ filter.RegisterHttpFilter(&Plugin{})
+}
+
+type (
+ // Plugin is http filter plugin.
+ Plugin struct {
+ }
+
+ // Filter is http filter instance
+ Filter struct {
+ cfg *Config
+ errMsg []byte
+ providerJwks map[string]Provider
+ }
+
+ // Config describe the config of Filter
+ Config struct {
+ ErrMsg string `yaml:"err_msg" json:"err_msg" mapstructure:"err_msg"`
+ Rules []Rules `yaml:"rules" json:"rules" mapstructure:"rules"`
+ Providers []Providers `yaml:"providers" json:"providers" mapstructure:"providers"`
+ }
+)
+
+func (p Plugin) Kind() string {
+ return Kind
+}
+
+func (p *Plugin) CreateFilter() (filter.HttpFilter, error) {
+ return &Filter{cfg: &Config{}, providerJwks: map[string]Provider{}}, nil
+}
+
+func (f *Filter) PrepareFilterChain(ctx *http.HttpContext) error {
+ ctx.AppendFilterFunc(f.Handle)
+ return nil
+}
+
+func (f *Filter) Handle(ctx *http.HttpContext) {
+
+ path := ctx.Request.RequestURI
+
+ router := false
+
+ for _, rule := range f.cfg.Rules {
+ if strings.HasPrefix(path, rule.Match.Prefix) {
+ router = true
+ if f.validAny(rule, ctx) || f.validAll(rule, ctx) {
+ ctx.Next()
+ break
+ }
+ }
+ }
+
+ if router {
+ ctx.WriteJSONWithStatus(stdHttp.StatusUnauthorized, f.errMsg)
+ ctx.Abort()
+ return
+ }
+
+ ctx.Next()
+
+}
+
+func valuePrefix(value, prefix string) string {
+ if prefix == "" {
+ return value
+ }
+ return strings.TrimPrefix(value, prefix)
+}
+
+func (f *Filter) validAny(rule Rules, ctx *http.HttpContext) bool {
+
+ providerName := rule.Requires.RequiresAny.ProviderName
+
+ if provider, ok := f.providerJwks[providerName]; ok {
+ ctx.Request.Header.Set(provider.forwardPayloadHeader, provider.issuer)
+ if key := ctx.Request.Header.Get(provider.headers.Name); key != "" {
+ token, err := jwt4.Parse(valuePrefix(key, provider.headers.ValuePrefix), provider.jwk.Keyfunc)
+ if err != nil {
+ logger.Warnf("failed to parse JWKs from JSON. provider:%s Error: %s", providerName, err.Error())
+ return false
+ }
+ return token.Valid
+ }
+ }
+
+ return false
Review comment:
validAny和 validAll 函数的语义辛苦加一下注释
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] codecov-commenter edited a comment on pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#issuecomment-976194931
# [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#303](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7cd11ca) into [develop](https://codecov.io/gh/apache/dubbo-go-pixiu/commit/63637b16d46a3f20ad482f20314e1ddc5c7256f3?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (63637b1) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## develop #303 +/- ##
========================================
Coverage 36.01% 36.01%
========================================
Files 55 55
Lines 3301 3301
========================================
Hits 1189 1189
Misses 1992 1992
Partials 120 120
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [63637b1...7cd11ca](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] baerwang commented on a change in pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
baerwang commented on a change in pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#discussion_r754009773
##########
File path: samples/dubbogo/simple/jwt/test/pixiu_test.go
##########
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jwt
+
+import (
+ "io/ioutil"
+ "net/http"
+ "strings"
+ "testing"
+ "time"
+)
+
+import (
+ "github.com/stretchr/testify/assert"
+)
+
+func TestLocalRemote(t *testing.T) {
+ client := &http.Client{Timeout: 5 * time.Second}
+ req, err := http.NewRequest(http.MethodGet, "http://localhost:1314/remote", nil)
+ assert.NoError(t, err)
+ resp, err := client.Do(req)
+ assert.NoError(t, err)
+ assert.Equal(t, http.StatusOK, resp.StatusCode)
+ assert.NotNil(t, resp)
+}
+
+func TestLocal(t *testing.T) {
+
+ verify(t, "http://localhost:8888/health", http.StatusUnauthorized)
+
+ s := verify(t, "http://localhost:8888/user", http.StatusOK)
+ assert.True(t, strings.Contains(s, "user"))
+
+ s = verify(t, "http://localhost:8888/user/pixiu", http.StatusOK)
+ assert.True(t, strings.Contains(s, "pixiu"))
+
+ s = verify(t, "http://localhost:8888/prefix", http.StatusOK)
+ assert.True(t, strings.Contains(s, "prefix"))
+}
+
+func TestRemote(t *testing.T) {
+ s := verify(t, "http://localhost:8888/prefix", http.StatusOK)
+ assert.True(t, strings.Contains(s, "prefix"))
+}
+
+func verify(t *testing.T, url string, status int) string {
+ var token = "eyJraWQiOiJlZThkNjI2ZCIsInR5cCI6IkpXVCIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiJXZWlkb25nIiwiYXVkIjoiVGFzaHVhbiIsImlzcyI6Imp3a3Mtc2VydmljZS5hcHBzcG90LmNvbSIsImlhdCI6MTYzMTM2OTk1NSwianRpIjoiNDY2M2E5MTAtZWU2MC00NzcwLTgxNjktY2I3NDdiMDljZjU0In0.LwD65d5h6U_2Xco81EClMa_1WIW4xXZl8o4b7WzY_7OgPD2tNlByxvGDzP7bKYA9Gj--1mi4Q4li4CAnKJkaHRYB17baC0H5P9lKMPuA6AnChTzLafY6yf-YadA7DmakCtIl7FNcFQQL2DXmh6gS9J6TluFoCIXj83MqETbDWpL28o3XAD_05UP8VLQzH2XzyqWKi97mOuvz-GsDp9mhBYQUgN3csNXt2v2l-bUPWe19SftNej0cxddyGu06tXUtaS6K0oe0TTbaqc3hmfEiu5G0J8U6ztTUMwXkBvaknE640NPgMQJqBaey0E4u0txYgyvMvvxfwtcOrDRYqYPBnA"
Review comment:
token可以定义,鉴权拒绝可以加个msg提示
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] baerwang commented on a change in pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
baerwang commented on a change in pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#discussion_r757840543
##########
File path: pkg/filter/auth/jwt/jwt.go
##########
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jwt
+
+import (
+ "encoding/json"
+ "fmt"
+ stdHttp "net/http"
+ "strings"
+ "time"
+)
+
+import (
+ "github.com/MicahParks/keyfunc"
+ jwt4 "github.com/golang-jwt/jwt/v4"
+)
+
+import (
+ "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
+ "github.com/apache/dubbo-go-pixiu/pkg/common/extension/filter"
+ "github.com/apache/dubbo-go-pixiu/pkg/context/http"
+ "github.com/apache/dubbo-go-pixiu/pkg/logger"
+)
+
+const (
+ Kind = constant.HTTPAuthJwtFilter
+)
+
+func init() {
+ filter.RegisterHttpFilter(&Plugin{})
+}
+
+type (
+ // Plugin is http filter plugin.
+ Plugin struct {
+ }
+
+ // Filter is http filter instance
+ Filter struct {
+ cfg *Config
+ errMsg []byte
+ providerJwks map[string]Provider
+ }
+
+ // Config describe the config of Filter
+ Config struct {
+ ErrMsg string `yaml:"err_msg" json:"err_msg" mapstructure:"err_msg"`
+ Rules []Rules `yaml:"rules" json:"rules" mapstructure:"rules"`
+ Providers []Providers `yaml:"providers" json:"providers" mapstructure:"providers"`
+ }
+)
+
+func (p Plugin) Kind() string {
+ return Kind
+}
+
+func (p *Plugin) CreateFilter() (filter.HttpFilter, error) {
+ return &Filter{cfg: &Config{}, providerJwks: map[string]Provider{}}, nil
+}
+
+func (f *Filter) PrepareFilterChain(ctx *http.HttpContext) error {
+ ctx.AppendFilterFunc(f.Handle)
+ return nil
+}
+
+func (f *Filter) Handle(ctx *http.HttpContext) {
+
+ path := ctx.Request.RequestURI
+
+ router := false
+
+ for _, rule := range f.cfg.Rules {
+ if strings.HasPrefix(path, rule.Match.Prefix) {
+ router = true
+ if f.validAny(rule, ctx) || f.validAll(rule, ctx) {
+ ctx.Next()
+ break
+ }
+ }
+ }
+
+ if router {
Review comment:
这是判断路由是否存在,存在的话没有通过valid就返回401
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] codecov-commenter edited a comment on pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#issuecomment-976194931
# [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#303](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8aa1ce0) into [develop](https://codecov.io/gh/apache/dubbo-go-pixiu/commit/9f72545a05da05a9bf13665dd932f5cc45709ebf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9f72545) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## develop #303 +/- ##
========================================
Coverage 36.04% 36.04%
========================================
Files 55 55
Lines 3299 3299
========================================
Hits 1189 1189
Misses 1991 1991
Partials 119 119
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [9f72545...8aa1ce0](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] codecov-commenter edited a comment on pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#issuecomment-976194931
# [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#303](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (64b35a3) into [develop](https://codecov.io/gh/apache/dubbo-go-pixiu/commit/11535b0fd11ac4d5f676148dc0ad8e64e730757e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (11535b0) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## develop #303 +/- ##
========================================
Coverage 36.14% 36.14%
========================================
Files 55 55
Lines 3295 3295
========================================
Hits 1191 1191
Misses 1985 1985
Partials 119 119
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [11535b0...64b35a3](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] codecov-commenter edited a comment on pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#issuecomment-976194931
# [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#303](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8aa1ce0) into [develop](https://codecov.io/gh/apache/dubbo-go-pixiu/commit/9f72545a05da05a9bf13665dd932f5cc45709ebf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9f72545) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## develop #303 +/- ##
========================================
Coverage 36.04% 36.04%
========================================
Files 55 55
Lines 3299 3299
========================================
Hits 1189 1189
Misses 1991 1991
Partials 119 119
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [9f72545...8aa1ce0](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] mark4z merged pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
mark4z merged pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] codecov-commenter edited a comment on pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#issuecomment-976194931
# [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#303](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (4ac08df) into [develop](https://codecov.io/gh/apache/dubbo-go-pixiu/commit/d1930df3e910c5f948380c703fbbce4f49490d2d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d1930df) will **not change** coverage.
> The diff coverage is `n/a`.
> :exclamation: Current head 4ac08df differs from pull request most recent head 85af2ed. Consider uploading reports for the commit 85af2ed to get more accurate results
[](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## develop #303 +/- ##
========================================
Coverage 33.93% 33.93%
========================================
Files 61 61
Lines 3165 3165
========================================
Hits 1074 1074
Misses 1979 1979
Partials 112 112
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [d1930df...85af2ed](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] mark4z commented on a change in pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
mark4z commented on a change in pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#discussion_r757508564
##########
File path: pkg/filter/auth/jwt/jwt.go
##########
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jwt
+
+import (
+ "encoding/json"
+ "fmt"
+ stdHttp "net/http"
+ "strings"
+ "time"
+)
+
+import (
+ "github.com/MicahParks/keyfunc"
+ jwt4 "github.com/golang-jwt/jwt/v4"
+)
+
+import (
+ "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
+ "github.com/apache/dubbo-go-pixiu/pkg/common/extension/filter"
+ "github.com/apache/dubbo-go-pixiu/pkg/context/http"
+ "github.com/apache/dubbo-go-pixiu/pkg/logger"
+)
+
+const (
+ Kind = constant.HTTPAuthJwtFilter
+)
+
+func init() {
+ filter.RegisterHttpFilter(&Plugin{})
+}
+
+type (
+ // Plugin is http filter plugin.
+ Plugin struct {
+ }
+
+ // Filter is http filter instance
+ Filter struct {
+ cfg *Config
+ errMsg []byte
+ providerJwks map[string]Provider
+ }
+
+ // Config describe the config of Filter
+ Config struct {
+ ErrMsg string `yaml:"err_msg" json:"err_msg" mapstructure:"err_msg"`
+ Rules []Rules `yaml:"rules" json:"rules" mapstructure:"rules"`
+ Providers []Providers `yaml:"providers" json:"providers" mapstructure:"providers"`
+ }
+)
+
+func (p Plugin) Kind() string {
+ return Kind
+}
+
+func (p *Plugin) CreateFilter() (filter.HttpFilter, error) {
+ return &Filter{cfg: &Config{}, providerJwks: map[string]Provider{}}, nil
+}
+
+func (f *Filter) PrepareFilterChain(ctx *http.HttpContext) error {
+ ctx.AppendFilterFunc(f.Handle)
+ //f.Handle(ctx)
+ return nil
+}
+
+func (f *Filter) Handle(ctx *http.HttpContext) {
+
+ path := ctx.Request.RequestURI
+
+ router := false
+
+ for _, rule := range f.cfg.Rules {
+ if strings.HasPrefix(path, rule.Match.Prefix) {
+ router = true
+ if f.validAny(rule, ctx) || f.validAll(rule, ctx) {
+ ctx.Next()
Review comment:
Do not invoke ctx.Next() here.
##########
File path: pkg/filter/auth/jwt/jwt.go
##########
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jwt
+
+import (
+ "encoding/json"
+ "fmt"
+ stdHttp "net/http"
+ "strings"
+ "time"
+)
+
+import (
+ "github.com/MicahParks/keyfunc"
+ jwt4 "github.com/golang-jwt/jwt/v4"
+)
+
+import (
+ "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
+ "github.com/apache/dubbo-go-pixiu/pkg/common/extension/filter"
+ "github.com/apache/dubbo-go-pixiu/pkg/context/http"
+ "github.com/apache/dubbo-go-pixiu/pkg/logger"
+)
+
+const (
+ Kind = constant.HTTPAuthJwtFilter
+)
+
+func init() {
+ filter.RegisterHttpFilter(&Plugin{})
+}
+
+type (
+ // Plugin is http filter plugin.
+ Plugin struct {
+ }
+
+ // Filter is http filter instance
+ Filter struct {
+ cfg *Config
+ errMsg []byte
+ providerJwks map[string]Provider
+ }
+
+ // Config describe the config of Filter
+ Config struct {
+ ErrMsg string `yaml:"err_msg" json:"err_msg" mapstructure:"err_msg"`
+ Rules []Rules `yaml:"rules" json:"rules" mapstructure:"rules"`
+ Providers []Providers `yaml:"providers" json:"providers" mapstructure:"providers"`
+ }
+)
+
+func (p Plugin) Kind() string {
+ return Kind
+}
+
+func (p *Plugin) CreateFilter() (filter.HttpFilter, error) {
+ return &Filter{cfg: &Config{}, providerJwks: map[string]Provider{}}, nil
+}
+
+func (f *Filter) PrepareFilterChain(ctx *http.HttpContext) error {
+ ctx.AppendFilterFunc(f.Handle)
+ //f.Handle(ctx)
Review comment:
remove unused code
##########
File path: go.mod
##########
@@ -4,33 +4,49 @@ go 1.15
require (
dubbo.apache.org/dubbo-go/v3 v3.0.0-rc4-1
+ github.com/MicahParks/keyfunc v0.10.0
+ github.com/RoaringBitmap/roaring v0.7.1 // indirect
Review comment:
// indirect
It's necessary?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] mark4z closed pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
mark4z closed pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] LaurenceLiZhixin commented on a change in pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
LaurenceLiZhixin commented on a change in pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#discussion_r753993919
##########
File path: samples/dubbogo/simple/jwt/test/pixiu_test.go
##########
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jwt
+
+import (
+ "io/ioutil"
+ "net/http"
+ "strings"
+ "testing"
+ "time"
+)
+
+import (
+ "github.com/stretchr/testify/assert"
+)
+
+func TestLocalRemote(t *testing.T) {
+ client := &http.Client{Timeout: 5 * time.Second}
+ req, err := http.NewRequest(http.MethodGet, "http://localhost:1314/remote", nil)
+ assert.NoError(t, err)
+ resp, err := client.Do(req)
+ assert.NoError(t, err)
+ assert.Equal(t, http.StatusOK, resp.StatusCode)
+ assert.NotNil(t, resp)
+}
+
+func TestLocal(t *testing.T) {
+
+ verify(t, "http://localhost:8888/health", http.StatusUnauthorized)
+
+ s := verify(t, "http://localhost:8888/user", http.StatusOK)
+ assert.True(t, strings.Contains(s, "user"))
+
+ s = verify(t, "http://localhost:8888/user/pixiu", http.StatusOK)
+ assert.True(t, strings.Contains(s, "pixiu"))
+
+ s = verify(t, "http://localhost:8888/prefix", http.StatusOK)
+ assert.True(t, strings.Contains(s, "prefix"))
+}
+
+func TestRemote(t *testing.T) {
+ s := verify(t, "http://localhost:8888/prefix", http.StatusOK)
+ assert.True(t, strings.Contains(s, "prefix"))
+}
+
+func verify(t *testing.T, url string, status int) string {
+ var token = "eyJraWQiOiJlZThkNjI2ZCIsInR5cCI6IkpXVCIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiJXZWlkb25nIiwiYXVkIjoiVGFzaHVhbiIsImlzcyI6Imp3a3Mtc2VydmljZS5hcHBzcG90LmNvbSIsImlhdCI6MTYzMTM2OTk1NSwianRpIjoiNDY2M2E5MTAtZWU2MC00NzcwLTgxNjktY2I3NDdiMDljZjU0In0.LwD65d5h6U_2Xco81EClMa_1WIW4xXZl8o4b7WzY_7OgPD2tNlByxvGDzP7bKYA9Gj--1mi4Q4li4CAnKJkaHRYB17baC0H5P9lKMPuA6AnChTzLafY6yf-YadA7DmakCtIl7FNcFQQL2DXmh6gS9J6TluFoCIXj83MqETbDWpL28o3XAD_05UP8VLQzH2XzyqWKi97mOuvz-GsDp9mhBYQUgN3csNXt2v2l-bUPWe19SftNej0cxddyGu06tXUtaS6K0oe0TTbaqc3hmfEiu5G0J8U6ztTUMwXkBvaknE640NPgMQJqBaey0E4u0txYgyvMvvxfwtcOrDRYqYPBnA"
Review comment:
这个token是如何下发的?用户可否自己定制 token 下发filter,以及鉴权拒绝逻辑
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] LaurenceLiZhixin commented on a change in pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
LaurenceLiZhixin commented on a change in pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#discussion_r754010787
##########
File path: samples/dubbogo/simple/jwt/test/pixiu_test.go
##########
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jwt
+
+import (
+ "io/ioutil"
+ "net/http"
+ "strings"
+ "testing"
+ "time"
+)
+
+import (
+ "github.com/stretchr/testify/assert"
+)
+
+func TestLocalRemote(t *testing.T) {
+ client := &http.Client{Timeout: 5 * time.Second}
+ req, err := http.NewRequest(http.MethodGet, "http://localhost:1314/remote", nil)
+ assert.NoError(t, err)
+ resp, err := client.Do(req)
+ assert.NoError(t, err)
+ assert.Equal(t, http.StatusOK, resp.StatusCode)
+ assert.NotNil(t, resp)
+}
+
+func TestLocal(t *testing.T) {
+
+ verify(t, "http://localhost:8888/health", http.StatusUnauthorized)
+
+ s := verify(t, "http://localhost:8888/user", http.StatusOK)
+ assert.True(t, strings.Contains(s, "user"))
+
+ s = verify(t, "http://localhost:8888/user/pixiu", http.StatusOK)
+ assert.True(t, strings.Contains(s, "pixiu"))
+
+ s = verify(t, "http://localhost:8888/prefix", http.StatusOK)
+ assert.True(t, strings.Contains(s, "prefix"))
+}
+
+func TestRemote(t *testing.T) {
+ s := verify(t, "http://localhost:8888/prefix", http.StatusOK)
+ assert.True(t, strings.Contains(s, "prefix"))
+}
+
+func verify(t *testing.T, url string, status int) string {
+ var token = "eyJraWQiOiJlZThkNjI2ZCIsInR5cCI6IkpXVCIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiJXZWlkb25nIiwiYXVkIjoiVGFzaHVhbiIsImlzcyI6Imp3a3Mtc2VydmljZS5hcHBzcG90LmNvbSIsImlhdCI6MTYzMTM2OTk1NSwianRpIjoiNDY2M2E5MTAtZWU2MC00NzcwLTgxNjktY2I3NDdiMDljZjU0In0.LwD65d5h6U_2Xco81EClMa_1WIW4xXZl8o4b7WzY_7OgPD2tNlByxvGDzP7bKYA9Gj--1mi4Q4li4CAnKJkaHRYB17baC0H5P9lKMPuA6AnChTzLafY6yf-YadA7DmakCtIl7FNcFQQL2DXmh6gS9J6TluFoCIXj83MqETbDWpL28o3XAD_05UP8VLQzH2XzyqWKi97mOuvz-GsDp9mhBYQUgN3csNXt2v2l-bUPWe19SftNej0cxddyGu06tXUtaS6K0oe0TTbaqc3hmfEiu5G0J8U6ztTUMwXkBvaknE640NPgMQJqBaey0E4u0txYgyvMvvxfwtcOrDRYqYPBnA"
Review comment:
token 下发的接口网关会提供么?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] mark4z commented on a change in pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
mark4z commented on a change in pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#discussion_r754022991
##########
File path: samples/dubbogo/simple/jwt/test/pixiu_test.go
##########
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jwt
+
+import (
+ "io/ioutil"
+ "net/http"
+ "strings"
+ "testing"
+ "time"
+)
+
+import (
+ "github.com/stretchr/testify/assert"
+)
+
+func TestLocalRemote(t *testing.T) {
+ client := &http.Client{Timeout: 5 * time.Second}
+ req, err := http.NewRequest(http.MethodGet, "http://localhost:1314/remote", nil)
+ assert.NoError(t, err)
+ resp, err := client.Do(req)
+ assert.NoError(t, err)
+ assert.Equal(t, http.StatusOK, resp.StatusCode)
+ assert.NotNil(t, resp)
+}
+
+func TestLocal(t *testing.T) {
+
+ verify(t, "http://localhost:8888/health", http.StatusUnauthorized)
+
+ s := verify(t, "http://localhost:8888/user", http.StatusOK)
+ assert.True(t, strings.Contains(s, "user"))
+
+ s = verify(t, "http://localhost:8888/user/pixiu", http.StatusOK)
+ assert.True(t, strings.Contains(s, "pixiu"))
+
+ s = verify(t, "http://localhost:8888/prefix", http.StatusOK)
+ assert.True(t, strings.Contains(s, "prefix"))
+}
+
+func TestRemote(t *testing.T) {
+ s := verify(t, "http://localhost:8888/prefix", http.StatusOK)
+ assert.True(t, strings.Contains(s, "prefix"))
+}
+
+func verify(t *testing.T, url string, status int) string {
+ var token = "eyJraWQiOiJlZThkNjI2ZCIsInR5cCI6IkpXVCIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiJXZWlkb25nIiwiYXVkIjoiVGFzaHVhbiIsImlzcyI6Imp3a3Mtc2VydmljZS5hcHBzcG90LmNvbSIsImlhdCI6MTYzMTM2OTk1NSwianRpIjoiNDY2M2E5MTAtZWU2MC00NzcwLTgxNjktY2I3NDdiMDljZjU0In0.LwD65d5h6U_2Xco81EClMa_1WIW4xXZl8o4b7WzY_7OgPD2tNlByxvGDzP7bKYA9Gj--1mi4Q4li4CAnKJkaHRYB17baC0H5P9lKMPuA6AnChTzLafY6yf-YadA7DmakCtIl7FNcFQQL2DXmh6gS9J6TluFoCIXj83MqETbDWpL28o3XAD_05UP8VLQzH2XzyqWKi97mOuvz-GsDp9mhBYQUgN3csNXt2v2l-bUPWe19SftNej0cxddyGu06tXUtaS6K0oe0TTbaqc3hmfEiu5G0J8U6ztTUMwXkBvaknE640NPgMQJqBaey0E4u0txYgyvMvvxfwtcOrDRYqYPBnA"
Review comment:
这个应该不会,网关通常不负责这个吧
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] codecov-commenter edited a comment on pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#issuecomment-976194931
# [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#303](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7cd11ca) into [develop](https://codecov.io/gh/apache/dubbo-go-pixiu/commit/63637b16d46a3f20ad482f20314e1ddc5c7256f3?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (63637b1) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## develop #303 +/- ##
========================================
Coverage 36.01% 36.01%
========================================
Files 55 55
Lines 3301 3301
========================================
Hits 1189 1189
Misses 1992 1992
Partials 120 120
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [63637b1...7cd11ca](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] baerwang commented on a change in pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
baerwang commented on a change in pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#discussion_r758837735
##########
File path: pkg/filter/auth/jwt/jwt.go
##########
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jwt
+
+import (
+ "encoding/json"
+ "fmt"
+ stdHttp "net/http"
+ "strings"
+ "time"
+)
+
+import (
+ "github.com/MicahParks/keyfunc"
+ jwt4 "github.com/golang-jwt/jwt/v4"
+)
+
+import (
+ "github.com/apache/dubbo-go-pixiu/pkg/common/constant"
+ "github.com/apache/dubbo-go-pixiu/pkg/common/extension/filter"
+ "github.com/apache/dubbo-go-pixiu/pkg/context/http"
+ "github.com/apache/dubbo-go-pixiu/pkg/logger"
+)
+
+const (
+ Kind = constant.HTTPAuthJwtFilter
+)
+
+func init() {
+ filter.RegisterHttpFilter(&Plugin{})
+}
+
+type (
+ // Plugin is http filter plugin.
+ Plugin struct {
+ }
+
+ // Filter is http filter instance
+ Filter struct {
+ cfg *Config
+ errMsg []byte
+ providerJwks map[string]Provider
+ }
+
+ // Config describe the config of Filter
+ Config struct {
+ ErrMsg string `yaml:"err_msg" json:"err_msg" mapstructure:"err_msg"`
+ Rules []Rules `yaml:"rules" json:"rules" mapstructure:"rules"`
+ Providers []Providers `yaml:"providers" json:"providers" mapstructure:"providers"`
+ }
+)
+
+func (p Plugin) Kind() string {
+ return Kind
+}
+
+func (p *Plugin) CreateFilter() (filter.HttpFilter, error) {
+ return &Filter{cfg: &Config{}, providerJwks: map[string]Provider{}}, nil
+}
+
+func (f *Filter) PrepareFilterChain(ctx *http.HttpContext) error {
+ ctx.AppendFilterFunc(f.Handle)
+ return nil
+}
+
+func (f *Filter) Handle(ctx *http.HttpContext) {
+
+ path := ctx.Request.RequestURI
+
+ router := false
+
+ for _, rule := range f.cfg.Rules {
+ if strings.HasPrefix(path, rule.Match.Prefix) {
+ router = true
+ if f.validAny(rule, ctx) || f.validAll(rule, ctx) {
+ ctx.Next()
+ break
+ }
+ }
+ }
+
+ if router {
Review comment:
我看了下是有问题的,但是多了c.next(),下面的401就不管用了,等这几天修改下
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go-pixiu] codecov-commenter edited a comment on pull request #303: feat:auth filter
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #303:
URL: https://github.com/apache/dubbo-go-pixiu/pull/303#issuecomment-976194931
# [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#303](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b6023dc) into [develop](https://codecov.io/gh/apache/dubbo-go-pixiu/commit/11535b0fd11ac4d5f676148dc0ad8e64e730757e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (11535b0) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## develop #303 +/- ##
========================================
Coverage 36.14% 36.14%
========================================
Files 55 55
Lines 3295 3295
========================================
Hits 1191 1191
Misses 1985 1985
Partials 119 119
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [11535b0...b6023dc](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/303?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org