mirror of
https://github.com/1f349/lavender.git
synced 2024-11-09 22:32:48 +00:00
Add CORS headers to /verify endpoint
This commit is contained in:
parent
67be57b6b1
commit
be3a09b73a
@ -63,11 +63,11 @@ func NewHttpServer(conf Conf, signer mjwt.Signer) *HttpServer {
|
||||
rw.WriteHeader(http.StatusOK)
|
||||
_, _ = fmt.Fprintln(rw, "What is this?")
|
||||
})
|
||||
r.POST("/verify", hs.verifyHandler)
|
||||
r.GET("/popup", hs.flowPopup)
|
||||
r.POST("/popup", hs.flowPopupPost)
|
||||
r.GET("/callback", hs.flowCallback)
|
||||
|
||||
// setup CORS options for `/verify` and `/refresh` endpoints
|
||||
var corsAccessControl = cors.New(cors.Options{
|
||||
AllowOriginFunc: func(origin string) bool {
|
||||
load := hs.services.Load()
|
||||
@ -78,6 +78,13 @@ func NewHttpServer(conf Conf, signer mjwt.Signer) *HttpServer {
|
||||
AllowedHeaders: []string{"Content-Type"},
|
||||
AllowCredentials: true,
|
||||
})
|
||||
|
||||
// `/verify` and `/refresh` need CORS headers to be usable on other domains
|
||||
r.POST("/verify", func(rw http.ResponseWriter, req *http.Request, params httprouter.Params) {
|
||||
corsAccessControl.ServeHTTP(rw, req, func(writer http.ResponseWriter, request *http.Request) {
|
||||
hs.verifyHandler(rw, req, params)
|
||||
})
|
||||
})
|
||||
r.POST("/refresh", func(rw http.ResponseWriter, req *http.Request, params httprouter.Params) {
|
||||
corsAccessControl.ServeHTTP(rw, req, func(writer http.ResponseWriter, request *http.Request) {
|
||||
hs.refreshHandler(rw, req, params)
|
||||
|
Loading…
Reference in New Issue
Block a user