Skip to content

Commit 7345e97

Browse files
authored
add mfa bypass url (#4657)
Signed-off-by: Patrick Zhao <zhaoyu@koderover.com>
1 parent 536e9b7 commit 7345e97

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

pkg/microservice/user/server/grpc/server.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"fmt"
2323
"net/http"
2424
"net/url"
25+
"regexp"
2526
"strings"
2627
"time"
2728

@@ -47,6 +48,8 @@ const (
4748
mfaEnrollmentRequiredReason = "mfa_enrollment_required"
4849
mfaVerificationRequiredReason = "mfa_verification_required"
4950
mfaReasonHeaderKey = "x-zadig-auth-reason"
51+
52+
mfaEnrollmentBypassURLRegExp = `^/api/v1/users/[^/]+/mfa/[A-Za-z0-9_-]+$`
5053
)
5154

5255
func (s *AuthServer) Check(ctx context.Context, request *ext_authz_v3.CheckRequest) (*ext_authz_v3.CheckResponse, error) {
@@ -249,6 +252,11 @@ func isMFAGateBypassURL(requestPath, method string) bool {
249252
return true
250253
}
251254

255+
match, _ := regexp.MatchString(mfaEnrollmentBypassURLRegExp, path)
256+
if match && (method == http.MethodPost || method == http.MethodGet) {
257+
return true
258+
}
259+
252260
return false
253261
}
254262

0 commit comments

Comments
 (0)