-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update middleware skipper (#887)
* chore: update middleware skipper * chore: update
- Loading branch information
Showing
13 changed files
with
82 additions
and
156 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,6 @@ on: | |
branches: | ||
- main | ||
- "release/*.*.*" | ||
paths-ignore: | ||
- "web/**" | ||
|
||
jobs: | ||
go-static-checks: | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,6 @@ on: | |
branches: | ||
- main | ||
- "release/*.*.*" | ||
paths: | ||
- "web/**" | ||
|
||
jobs: | ||
eslint-checks: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,46 @@ | ||
package server | ||
|
||
func composeResponse(data interface{}) interface{} { | ||
type R struct { | ||
Data interface{} `json:"data"` | ||
} | ||
import ( | ||
"github.com/labstack/echo/v4" | ||
"github.com/usememos/memos/api" | ||
"github.com/usememos/memos/common" | ||
) | ||
|
||
type response struct { | ||
Data interface{} `json:"data"` | ||
} | ||
|
||
return R{ | ||
func composeResponse(data interface{}) response { | ||
return response{ | ||
Data: data, | ||
} | ||
} | ||
|
||
func (server *Server) DefaultAuthSkipper(c echo.Context) bool { | ||
ctx := c.Request().Context() | ||
path := c.Path() | ||
|
||
// Skip auth. | ||
if common.HasPrefixes(path, "/api/auth") { | ||
return true | ||
} | ||
|
||
// If there is openId in query string and related user is found, then skip auth. | ||
openID := c.QueryParam("openId") | ||
if openID != "" { | ||
userFind := &api.UserFind{ | ||
OpenID: &openID, | ||
} | ||
user, err := server.Store.FindUser(ctx, userFind) | ||
if err != nil && common.ErrorCode(err) != common.NotFound { | ||
return false | ||
} | ||
if user != nil { | ||
// Stores userID into context. | ||
c.Set(getUserIDContextKey(), user.ID) | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.