chore: fix jwt checks

This commit is contained in:
Steven 2023-11-05 23:39:30 +08:00
parent 39a0e69b04
commit c24181b2be
3 changed files with 3 additions and 5 deletions

View File

@ -60,7 +60,7 @@ func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) e
}
// Skip validation for server status endpoints.
if util.HasPrefixes(path, "/api/v1/ping", "/api/v1/idp", "/api/v1/status", "/api/v1/user") && path != "/api/v1/user/me" && method == http.MethodGet {
if util.HasPrefixes(path, "/api/v1/ping", "/api/v1/idp", "/api/v1/status", "/api/v1/user") && path != "/api/v1/user/me" && path != "/api/v1/user" && method == http.MethodGet {
return next(c)
}

View File

@ -61,8 +61,6 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
`"status":${status},"error":"${error}"}` + "\n",
}))
e.Use(middleware.Gzip())
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
Skipper: grpcRequestSkipper,
AllowOrigins: []string{"*"},

View File

@ -4,7 +4,7 @@ import { useEffect, useState } from "react";
import { toast } from "react-hot-toast";
import { userServiceClient } from "@/grpcweb";
import useCurrentUser from "@/hooks/useCurrentUser";
import { extractUsernameFromName } from "@/store/v1";
import { UserNamePrefix, extractUsernameFromName } from "@/store/v1";
import { UserAccessToken } from "@/types/proto/api/v2/user_service";
import { useTranslate } from "@/utils/i18n";
import showCreateAccessTokenDialog from "../CreateAccessTokenDialog";
@ -13,7 +13,7 @@ import Icon from "../Icon";
import LearnMore from "../LearnMore";
const listAccessTokens = async (username: string) => {
const { accessTokens } = await userServiceClient.listUserAccessTokens({ name: `${UserAccessToken}${username}` });
const { accessTokens } = await userServiceClient.listUserAccessTokens({ name: `${UserNamePrefix}${username}` });
return accessTokens;
};