You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/08/02 08:29:58 UTC
[GitHub] [servicecomb-service-center] Sphairis commented on a change in pull request #1119: add sign request for kie-client
Sphairis commented on a change in pull request #1119:
URL: https://github.com/apache/servicecomb-service-center/pull/1119#discussion_r680776366
##########
File path: server/service/rbac/context.go
##########
@@ -47,3 +51,24 @@ func AccountFromContext(ctx context.Context) (*rbacmodel.Account, error) {
}
return rbacmodel.GetAccount(m)
}
+
+func WithToken(req *http.Request, token string) *http.Request {
+ return util.SetRequestContext(req, CtxRequestToken, token)
+}
+
+func TokenFromRequest(req *http.Request) string {
+ token, ok := req.Context().Value(CtxRequestToken).(string)
+ if !ok {
+ return ""
+ }
+ return token
+}
+
+func SignRequest(req *http.Request) error {
+ token := TokenFromRequest(req)
+ if token == "" {
+ return errors.New("request unauthorized")
+ }
+ return nil
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: commits-unsubscribe@servicecomb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org