Skip to content

Commit

Permalink
feat(): add apis: AuthApi_checkLoginByName, AuthApi_switchOrg, Bootst…
Browse files Browse the repository at this point in the history
…rapStandaloneApi_batchDeleteBootstrapStandaloneCache, CustomAuthConfigApi_createBackendNode, CustomAuthConfigApi_updateBackendNode, SsoApi_validateAccessToken, SsoServerApi_index, SsoServerApi_oauthAccessToken, SsoServerApi_oauthUserInfo

INFRA-0
  • Loading branch information
easyops-eve committed May 9, 2024
1 parent 3ad1103 commit ab0f39d
Show file tree
Hide file tree
Showing 24 changed files with 983 additions and 13 deletions.
623 changes: 617 additions & 6 deletions sdk/api-gateway-sdk/contracts.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions sdk/api-gateway-sdk/src/api/api_gateway/auth/checkLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ export interface AuthApi_CheckLoginResponseBody {

/** 主名称 次名称 */
userShowValue?: string[];

/** SSO OAuth2 授权登录场景下,认证中心签发的令牌 */
accessToken?: string;
}

/**
Expand Down
40 changes: 40 additions & 0 deletions sdk/api-gateway-sdk/src/api/api_gateway/auth/checkLoginByName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { http, HttpOptions } from "@next-core/http";
import { ResponseBodyWrapper } from "../../../wrapper.js";

export interface AuthApi_CheckLoginByNameRequestBody {
/** 用户名 */
username?: string;

/** 客户id */
org?: number;
}

export interface AuthApi_CheckLoginByNameResponseBody {
/** 是否已经登录 */
loggedIn?: boolean;

/** 用户名 */
username?: string;

/** 客户id */
org?: number;

/** 登录Session */
loginSession?: string;
}

/**
* @description 判断用户是否登录
* @endpoint POST /api/auth/user/check/login
*/
export const AuthApi_checkLoginByName = async (
data: AuthApi_CheckLoginByNameRequestBody,
options?: HttpOptions
): Promise<AuthApi_CheckLoginByNameResponseBody> =>
/**! @contract easyops.api.api_gateway.auth.CheckLoginByName@1.2.0 */ (
await http.post<ResponseBodyWrapper<AuthApi_CheckLoginByNameResponseBody>>(
"api/auth/user/check/login",
data,
options
)
).data;
2 changes: 2 additions & 0 deletions sdk/api-gateway-sdk/src/api/api_gateway/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
export * from "./checkLogin.js";
export * from "./checkLoginByName.js";
export * from "./getCaptcha.js";
export * from "./ldapLogin.js";
export * from "./loginV2.js";
export * from "./logout.js";
export * from "./refreshToken.js";
export * from "./register.js";
export * from "./registerV2.js";
export * from "./switchOrg.js";
export * from "./tokenLdapLogin.js";
export * from "./tokenLogin.js";
9 changes: 9 additions & 0 deletions sdk/api-gateway-sdk/src/api/api_gateway/auth/loginV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ export interface AuthApi_LoginV2ResponseBody {

/** csrf_token,开启了csrf特性才返回值 */
csrfToken?: string;

/** 是否需要修改密码(开启 check-password-security 特性时, 初次登录和密码过期时需要修改密码) */
changePasswordRequired?: boolean;

/** 修改密码的具体原因(firstLogin:初次登录, expired:密码已过期) */
changePasswordReason?: "firstLogin" | "expired";

/** 密码有效期剩余时间(当 changePasswordRequired 为 true 时,这个值为 -1) */
passwordRemainingDays?: number;
}

/**
Expand Down
40 changes: 40 additions & 0 deletions sdk/api-gateway-sdk/src/api/api_gateway/auth/switchOrg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { http, HttpOptions } from "@next-core/http";
import { ResponseBodyWrapper } from "../../../wrapper.js";

export interface AuthApi_SwitchOrgRequestBody {
/** 切换到哪个组织 (具体是哪个用户切换组织,从 context 中获取 username) */
org: number;
}

export interface AuthApi_SwitchOrgResponseBody {
/** 用户名 */
username?: string;

/** 组织 org */
org?: number;

/** 用户 id */
userInstanceId?: string;

/** 判断当前登录用户是否是系统管理员 */
isAdmin?: boolean;

/** 主名称 次名称 */
userShowValue?: string[];
}

/**
* @description 多组织用户切换组织
* @endpoint POST /api/auth/login/switch_org
*/
export const AuthApi_switchOrg = async (
data: AuthApi_SwitchOrgRequestBody,
options?: HttpOptions
): Promise<AuthApi_SwitchOrgResponseBody> =>
/**! @contract easyops.api.api_gateway.auth.SwitchOrg@1.0.0 */ (
await http.post<ResponseBodyWrapper<AuthApi_SwitchOrgResponseBody>>(
"api/auth/login/switch_org",
data,
options
)
).data;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { http, HttpOptions } from "@next-core/http";

export interface BootstrapStandaloneApi_BatchDeleteBootstrapStandaloneCacheRequestBody {
/** 主页 */
homePage?: string[];
}

/**
* @description 批量删除独立小产品主页缓存
* @endpoint POST /api/v1/bootstrap_standalone_cache/batch_delete
*/
export const BootstrapStandaloneApi_batchDeleteBootstrapStandaloneCache = (
data: BootstrapStandaloneApi_BatchDeleteBootstrapStandaloneCacheRequestBody,
options?: HttpOptions
): Promise<void> =>
/**! @contract easyops.api.api_gateway.bootstrap_standalone.BatchDeleteBootstrapStandaloneCache@1.0.0 */ http.post<void>(
"api/v1/bootstrap_standalone_cache/batch_delete",
data,
options
);
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./batchDeleteBootstrapStandaloneCache.js";
export * from "./deleteBootstrapStandaloneCache.js";
export * from "./deleteLaunchpadEtagCache.js";
export * from "./getBrandFavicon.js";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { http, HttpOptions } from "@next-core/http";
import { ModelBackendNode } from "../../../model/api_gateway/index.js";
import { ResponseBodyWrapper } from "../../../wrapper.js";

export interface CustomAuthConfigApi_CreateBackendNodeRequestBody {
/** 节点 */
node?: Partial<ModelBackendNode>;

/** 关联的服务ID列表 */
serviceInstanceIds?: string[];
}

export interface CustomAuthConfigApi_CreateBackendNodeResponseBody {
/** 节点id */
id?: string;
}

/**
* @description 创建后端节点
* @endpoint POST /api/v1/api_gateway/backend_node
*/
export const CustomAuthConfigApi_createBackendNode = async (
data: CustomAuthConfigApi_CreateBackendNodeRequestBody,
options?: HttpOptions
): Promise<CustomAuthConfigApi_CreateBackendNodeResponseBody> =>
/**! @contract easyops.api.api_gateway.custom_auth_config.CreateBackendNode@1.4.0 */ (
await http.post<
ResponseBodyWrapper<CustomAuthConfigApi_CreateBackendNodeResponseBody>
>("api/v1/api_gateway/backend_node", data, options)
).data;
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export * from "./createBackendNode.js";
export * from "./createCustomAuthConfig.js";
export * from "./deleteCustomAuthConfig.js";
export * from "./getCustomAuthConfig.js";
export * from "./listCustomAuthConfig.js";
export * from "./oAuth2AccessTokenDebug.js";
export * from "./updateCustomAuthConfig.js";
export * from "./updateBackendNode.js";
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { http, HttpOptions } from "@next-core/http";
import { ModelBackendNode } from "../../../model/api_gateway/index.js";
import { ResponseBodyWrapper } from "../../../wrapper.js";

export interface CustomAuthConfigApi_UpdateBackendNodeRequestBody {
/** 节点 */
node?: Partial<ModelBackendNode>;

/** 解绑或者绑定服务 */
serviceOperation?: CustomAuthConfigApi_UpdateBackendNodeRequestBody_serviceOperation_item[];
}

export interface CustomAuthConfigApi_UpdateBackendNodeResponseBody {
/** 节点id */
id?: string;
}

/**
* @description 更新后端节点
* @endpoint PUT /api/v1/api_gateway/backend_node
*/
export const CustomAuthConfigApi_updateBackendNode = async (
data: CustomAuthConfigApi_UpdateBackendNodeRequestBody,
options?: HttpOptions
): Promise<CustomAuthConfigApi_UpdateBackendNodeResponseBody> =>
/**! @contract easyops.api.api_gateway.custom_auth_config.UpdateBackendNode@1.4.0 */ (
await http.put<
ResponseBodyWrapper<CustomAuthConfigApi_UpdateBackendNodeResponseBody>
>("api/v1/api_gateway/backend_node", data, options)
).data;

export interface CustomAuthConfigApi_UpdateBackendNodeRequestBody_serviceOperation_item {
/** 绑定/解绑 */
operate?: "append" | "remove";

/** 服务实例id */
instanceId?: string;
}
1 change: 1 addition & 0 deletions sdk/api-gateway-sdk/src/api/api_gateway/sso/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from "./ssoAuthorizeRedirect.js";
export * from "./ssoLogin.js";
export * from "./ssoLogout.js";
export * from "./ssoLogoutV2.js";
export * from "./validateAccessToken.js";
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { http, HttpOptions } from "@next-core/http";

/** 认证参数 */
export type SsoApi_SsoAuthorizeRedirectRequestBody = any;

/**
* @description SSO访问令牌认证; SSO身份认证成功后认证服务将会携带 登录凭证 重定向至该接口 (该接口最后会直接重定向到easyops平台的/next/sso-auth/authorize页面,可以是GET请求也可以是POST请求)
* @endpoint POST /api/v2/sso/authorization
* @endpoint POST /api/v2/sso/authorization/:protocol
*/
export const SsoApi_ssoAuthorizeRedirect = (
protocol: string | number,
data: SsoApi_SsoAuthorizeRedirectRequestBody,
options?: HttpOptions
): Promise<void> =>
/**! @contract easyops.api.api_gateway.sso.SSOAuthorizeRedirect@1.0.0 */ http.post<void>(
"api/v2/sso/authorization",
/**! @contract easyops.api.api_gateway.sso.SSOAuthorizeRedirect@1.0.1 */ http.post<void>(
`api/v2/sso/authorization/${protocol}`,
data,
options
);
29 changes: 29 additions & 0 deletions sdk/api-gateway-sdk/src/api/api_gateway/sso/validateAccessToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { http, HttpOptions } from "@next-core/http";
import { ResponseBodyWrapper } from "../../../wrapper.js";

export interface SsoApi_ValidateAccessTokenResponseBody {
/** 用户名 */
username?: string;

/** 用户ID */
userId?: string;

/** access token过期时长 */
expired?: number;

/** 昵称 */
nickname?: string;
}

/**
* @description 云盾平台子系统校验access token, 使用HEADER携带AccessToken
* @endpoint POST /api/v1/sso/auth/token/validate
*/
export const SsoApi_validateAccessToken = async (
options?: HttpOptions
): Promise<SsoApi_ValidateAccessTokenResponseBody> =>
/**! @contract easyops.api.api_gateway.sso.ValidateAccessToken@1.0.0 */ (
await http.post<
ResponseBodyWrapper<SsoApi_ValidateAccessTokenResponseBody>
>("api/v1/sso/auth/token/validate", undefined, options)
).data;
2 changes: 2 additions & 0 deletions sdk/api-gateway-sdk/src/api/api_gateway/sso_server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./oauthAccessToken.js";
export * from "./oauthUserInfo.js";
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { http, HttpOptions } from "@next-core/http";

export interface SsoServerApi_OauthAccessTokenRequestBody {
/** clientId */
client_id: string;

/** 可信任的密钥凭证 */
client_secret?: string;

/** 重定向uri */
redirect_uri: string;

/** 授权码,这里传拿到的授权码 */
code: string;

/** 授权类型,这里是使用授权码,传authorization_code */
grant_type: string;
}

export interface SsoServerApi_OauthAccessTokenResponseBody {
/** 生成的accessToken */
access_token?: string;

/** 超时时间,单位秒 */
expires_in?: number;

/** 访问令牌的类型,通常值为 "Bearer" */
token_type?: string;

/** 表示访问令牌的范围 */
scope?: string;

/** refresh_token,这里先声明这个字段,暂不生成 */
refresh_token?: string;
}

/**
* @description oauth2授权码模式,获取accessToken接口
* @endpoint POST /api/v1/api_gateway/sso_server/oauth2/access_token
*/
export const SsoServerApi_oauthAccessToken = (
data: SsoServerApi_OauthAccessTokenRequestBody,
options?: HttpOptions
): Promise<SsoServerApi_OauthAccessTokenResponseBody> =>
/**! @contract easyops.api.api_gateway.sso_server.OauthAccessToken@1.0.0 */ http.post<SsoServerApi_OauthAccessTokenResponseBody>(
"api/v1/api_gateway/sso_server/oauth2/access_token",
data,
options
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { http, HttpOptions } from "@next-core/http";

export interface SsoServerApi_OauthUserInfoResponseBody {
/** 用户信息 */
sub?: string;
}

/**
* @description oauth2授权码模式,获取userInfo接口
* @endpoint GET /api/v1/api_gateway/sso_server/oauth2/user_info
*/
export const SsoServerApi_oauthUserInfo = (
options?: HttpOptions
): Promise<SsoServerApi_OauthUserInfoResponseBody> =>
/**! @contract easyops.api.api_gateway.sso_server.OauthUserInfo@1.0.0 */ http.get<SsoServerApi_OauthUserInfoResponseBody>(
"api/v1/api_gateway/sso_server/oauth2/user_info",
options
);
1 change: 1 addition & 0 deletions sdk/api-gateway-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export * from "./api/api_gateway/mfa/index.js";
export * from "./api/api_gateway/oauth/index.js";
export * from "./api/api_gateway/org/index.js";
export * from "./api/api_gateway/sso/index.js";
export * from "./api/api_gateway/sso_server/index.js";
export * from "./api/api_gateway/union_pay/index.js";
export * from "./api/api_gateway/walmart/index.js";
export * from "./api/api_gateway/wechat/index.js";
Expand Down
20 changes: 20 additions & 0 deletions sdk/api-gateway-sdk/src/model/api_gateway/ModelBackendNode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/** 后端节点 */
export interface ModelBackendNode {
/** 实例ID */
instanceId: string;

/** ip/host */
ip: string;

/** port */
port: number;

/** 协议 */
scheme: "http" | "https";

/** 是否启用 */
enabled: boolean;

/** 权重 */
weight: number;
}
1 change: 1 addition & 0 deletions sdk/api-gateway-sdk/src/model/api_gateway/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from "./ModelStoryBoard.js";
export * from "./ModelDesktopItem.js";
export * from "./ModelDesktop.js";
export * from "./ModelSiteMap.js";
export * from "./ModelBackendNode.js";
export * from "./ModelCustomAuthConfigBasicAuth.js";
export * from "./ModelCustomAuthConfigApiKey.js";
export * from "./ModelCustomAuthConfigOAuth2.js";
Expand Down
Loading

0 comments on commit ab0f39d

Please sign in to comment.