|
@@ -3,13 +3,14 @@ package main |
|
@@ -3,13 +3,14 @@ package main |
3
|
import (
|
3
|
import (
|
4
|
"context"
|
4
|
"context"
|
5
|
"flag"
|
5
|
"flag"
|
|
|
6
|
+ "net/http"
|
|
|
7
|
+ "strings"
|
|
|
8
|
+
|
6
|
"github.com/zeromicro/go-zero/rest/httpx"
|
9
|
"github.com/zeromicro/go-zero/rest/httpx"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
|
12
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
|
13
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
|
11
|
- "net/http"
|
|
|
12
|
- "strings"
|
|
|
13
|
|
14
|
|
14
|
"github.com/golang-jwt/jwt/v4/request"
|
15
|
"github.com/golang-jwt/jwt/v4/request"
|
15
|
"github.com/zeromicro/go-zero/core/conf"
|
16
|
"github.com/zeromicro/go-zero/core/conf"
|
|
@@ -65,7 +66,8 @@ func systemSetup(c config.Config) { |
|
@@ -65,7 +66,8 @@ func systemSetup(c config.Config) { |
65
|
|
66
|
|
66
|
// 默认的token头 Authorization 修改为 x-mmm-accesstoken
|
67
|
// 默认的token头 Authorization 修改为 x-mmm-accesstoken
|
67
|
request.AuthorizationHeaderExtractor = &request.PostExtractionFilter{
|
68
|
request.AuthorizationHeaderExtractor = &request.PostExtractionFilter{
|
68
|
- request.HeaderExtractor{"x-mmm-accesstoken"}, func(tok string) (string, error) {
|
69
|
+ Extractor: request.HeaderExtractor{"x-mmm-accesstoken"},
|
|
|
70
|
+ Filter: func(tok string) (string, error) {
|
69
|
// Should be a bearer token
|
71
|
// Should be a bearer token
|
70
|
if len(tok) > 6 && strings.ToUpper(tok[0:7]) == "BEARER " {
|
72
|
if len(tok) > 6 && strings.ToUpper(tok[0:7]) == "BEARER " {
|
71
|
return tok[7:], nil
|
73
|
return tok[7:], nil
|