Skip to content

Commit

Permalink
fix: get domain list with iam and hide share dir for iam and share bu…
Browse files Browse the repository at this point in the history
…cket
  • Loading branch information
lihsai0 committed Jun 26, 2024
1 parent a746d12 commit 8459721
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kodo-browser",
"version": "2.3.0",
"version": "2.3.1",
"license": "Apache-2.0",
"author": {
"name": "Rong Zhou",
Expand Down Expand Up @@ -111,7 +111,7 @@
"form-data": "^4.0.0",
"js-base64": "^3.4.5",
"js-md5": "^0.7.3",
"kodo-s3-adapter-sdk": "0.6.0",
"kodo-s3-adapter-sdk": "0.6.1",
"lockfile": "^1.0.4",
"lodash": "^4.17.21",
"mime": "^2.3.1",
Expand Down
14 changes: 13 additions & 1 deletion src/renderer/modules/auth/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import lodash from "lodash";
import * as LocalLogger from "@renderer/modules/local-logger";
import * as QiniuClient from "@renderer/modules/qiniu-client";

import {AkItem, EndpointType, ShareSession} from "./types";
import {AkItem, AkSpecialType, EndpointType, ShareSession} from "./types";
import {authPersistence} from "./persistence";

let currentUser: AkItem | null = null;
Expand Down Expand Up @@ -32,6 +32,7 @@ export async function signIn(akItem: AkItem, remember: boolean) {
QiniuClient.clearAllCache();
throw err;
}
akItem.specialType = getAkSpecialType(akItem.accessKey);
currentUser = akItem;
if (remember) {
await authPersistence.save(akItem);
Expand Down Expand Up @@ -78,6 +79,7 @@ export async function signInWithShareLink({
endpointType: EndpointType.ShareSession,
accessKey: verifyShareResult.federated_ak,
accessSecret: verifyShareResult.federated_sk,
specialType: getAkSpecialType(verifyShareResult.federated_ak),
};
shareSession = {
sessionToken: verifyShareResult.session_token,
Expand Down Expand Up @@ -108,6 +110,7 @@ export async function signInWithShareSession({
currentUser = {
...akItem,
endpointType: EndpointType.ShareSession,
specialType: getAkSpecialType(akItem.accessKey),
};
shareSession = session;
// do not remember always;
Expand All @@ -124,6 +127,15 @@ export function getCurrentUser(): AkItem | null {
return currentUser;
}

export function getAkSpecialType(accessKey: string = ""): AkSpecialType | undefined {
if (accessKey.length === 44 && accessKey.startsWith("IAM-")) {
return AkSpecialType.IAM;
} else if (accessKey.startsWith("STS-")) {
return AkSpecialType.STS;
}
return;
}

export function getShareSession(): ShareSession | null {
return shareSession;
}
Expand Down
6 changes: 6 additions & 0 deletions src/renderer/modules/auth/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ export enum EndpointType {
ShareSession = "shareSession",
}

export enum AkSpecialType {
IAM = "IAM",
STS = "STS",
}

export interface AkItem {
endpointType: EndpointType,
accessKey: string,
accessSecret: string,
specialType?: AkSpecialType,
description?: string,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ const FileOperations: React.FC<RowCellDataProps & FileOperationsCellCallbackProp
const canRestore = isFile && ["Archive", "DeepArchive"].includes(file.storageClass);

const shouldShowShareDirButton = useMemo(() => {
if (isFile || !currentUser) {
if (
isFile ||
!currentUser ||
currentUser.specialType ||
bucketGrantedPermission
) {
return false;
}

Expand Down

0 comments on commit 8459721

Please sign in to comment.