File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ func main() {
32
32
_ , _ = w .Write ([]byte ("pong" ))
33
33
}).Methods (http .MethodGet )
34
34
r .HandleFunc ("/auth" , auth .HandleAuth ).Methods (http .MethodPost )
35
+ r .HandleFunc ("/auth/customsecurity/{customSchemeType}" , auth .HandleCustomAuth ).Methods (http .MethodGet )
35
36
r .HandleFunc ("/requestbody" , requestbody .HandleRequestBody ).Methods (http .MethodPost )
36
37
r .HandleFunc ("/vendorjson" , responseHeaders .HandleVendorJsonResponseHeaders ).Methods (http .MethodGet )
37
38
r .HandleFunc ("/pagination/limitoffset/page" , pagination .HandleLimitOffsetPage ).Methods (http .MethodGet , http .MethodPut )
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package auth
2
2
3
3
import (
4
4
"encoding/json"
5
+ "fmt"
5
6
"io"
6
7
"net/http"
7
8
@@ -28,3 +29,22 @@ func HandleAuth(w http.ResponseWriter, r *http.Request) {
28
29
return
29
30
}
30
31
}
32
+
33
+ func HandleCustomAuth (w http.ResponseWriter , r * http.Request ) {
34
+ switch r .URL .Path {
35
+ case "/auth/customsecurity/customSchemeAppId" :
36
+ appID := r .Header .Get ("X-Security-App-Id" )
37
+ if appID != "testAppID" {
38
+ utils .HandleError (w , fmt .Errorf ("invalid app id: %w" , authError ))
39
+ return
40
+ }
41
+ secret := r .Header .Get ("X-Security-Secret" )
42
+ if secret != "testSecret" {
43
+ utils .HandleError (w , fmt .Errorf ("invalid secret: %w" , authError ))
44
+ return
45
+ }
46
+ default :
47
+ utils .HandleError (w , fmt .Errorf ("invalid path" ))
48
+ return
49
+ }
50
+ }
You can’t perform that action at this time.
0 commit comments