Skip to content

Commit

Permalink
chore: from main
Browse files Browse the repository at this point in the history
  • Loading branch information
wzh425 committed May 9, 2024
2 parents 5eb97c6 + 291bb15 commit 7989ae9
Show file tree
Hide file tree
Showing 185 changed files with 11,997 additions and 674 deletions.
34 changes: 17 additions & 17 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ stages:
- docker-dev
- deploy-dev
- deploy-test
- deploy-staging
#- deploy-staging
- docker-prd
- deploy-prd

Expand Down Expand Up @@ -50,7 +50,7 @@ deploy-dev:
only:
- main
script:
- echo $KUBE_CONFIG_MASA_YDY | base64 -d > ./config
- echo $KUBE_CONFIG_NEW_YDY | base64 -d > ./config
- echo $CI_PIPELINE_ID
- kubectl --kubeconfig ./config set image deployment/auth auth=$IMAGE_AUTH_WEB_ADMIN_SERVER_DEV -n $NAMESPACE_DEV
- kubectl --kubeconfig ./config set image deployment/auth-service auth-service=$IMAGE_AUTH_SERVER_ADMIN_DEV -n $NAMESPACE_DEV
Expand All @@ -63,27 +63,27 @@ deploy-test:
only:
- main
script:
- echo $KUBE_CONFIG_MASA_YDY | base64 -d > ./config
- echo $KUBE_CONFIG_NEW_YDY | base64 -d > ./config
- echo $CI_PIPELINE_ID
- kubectl --kubeconfig ./config set image deployment/auth auth=$IMAGE_AUTH_WEB_ADMIN_SERVER_DEV -n $NAMESPACE_TEST
- kubectl --kubeconfig ./config set image deployment/auth-service auth-service=$IMAGE_AUTH_SERVER_ADMIN_DEV -n $NAMESPACE_TEST
- kubectl --kubeconfig ./config set image deployment/auth-sso auth-sso=$IMAGE_AUTH_WEB_ADMIN_SSO_DEV -n $NAMESPACE_TEST
retry: 2
when: manual

deploy-staging:
stage: deploy-staging
image: registry.cn-hangzhou.aliyuncs.com/masa/library:kubectl-shell-v1.21.1
only:
- main
script:
- echo $KUBE_CONFIG_MASA_YDY | base64 -d > ./config
- echo $CI_PIPELINE_ID
- kubectl --kubeconfig ./config set image deployment/auth auth=$IMAGE_AUTH_WEB_ADMIN_SERVER_DEV -n $NAMESPACE_STAGING
- kubectl --kubeconfig ./config set image deployment/auth-service auth-service=$IMAGE_AUTH_SERVER_ADMIN_DEV -n $NAMESPACE_STAGING
- kubectl --kubeconfig ./config set image deployment/auth-sso auth-sso=$IMAGE_AUTH_WEB_ADMIN_SSO_DEV -n $NAMESPACE_STAGING
retry: 2
when: manual
# deploy-staging:
# stage: deploy-staging
# image: registry.cn-hangzhou.aliyuncs.com/masa/library:kubectl-shell-v1.21.1
# only:
# - main
# script:
# - echo $KUBE_CONFIG_NEW_YDY | base64 -d > ./config
# - echo $CI_PIPELINE_ID
# - kubectl --kubeconfig ./config set image deployment/auth auth=$IMAGE_AUTH_WEB_ADMIN_SERVER_DEV -n $NAMESPACE_STAGING
# - kubectl --kubeconfig ./config set image deployment/auth-service auth-service=$IMAGE_AUTH_SERVER_ADMIN_DEV -n $NAMESPACE_STAGING
# - kubectl --kubeconfig ./config set image deployment/auth-sso auth-sso=$IMAGE_AUTH_WEB_ADMIN_SSO_DEV -n $NAMESPACE_STAGING
# retry: 2
# when: manual

docker-prd:
stage: docker-prd
Expand All @@ -110,7 +110,7 @@ deploy-prd:
only:
- tags
script:
- echo $KUBE_CONFIG_MASA_PRD | base64 -d > ./config
- echo $KUBE_CONFIG_LSD_PRD_YDY | base64 -d > ./config
- echo $CI_COMMIT_TAG
- kubectl --kubeconfig ./config set image deployment/auth auth=$IMAGE_AUTH_WEB_ADMIN_SERVER -n $NAMESPACE_PRD
- kubectl --kubeconfig ./config set image deployment/auth-service auth-service=$IMAGE_AUTH_SERVER_ADMIN -n $NAMESPACE_PRD
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<WarningsAsErrors>
$(WarningsAsErrors);CS8600;CS8601;CS8602;CS8603;CS8604;CS8609;CS8610;CS8614;CS8616;CS8618;CS8619;CS8622;CS8625
</WarningsAsErrors>
<MasaFrameworkPackageVersion>1.0.1-preview.1</MasaFrameworkPackageVersion>
<MasaFrameworkPackageVersion>1.0.1-preview.17</MasaFrameworkPackageVersion>
</PropertyGroup>
</Project>
34 changes: 4 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,11 @@
</a>
</p>

## 介绍
## Introduction

MASA Auth是MASA Stack中最核心的功能之一,它统一负责了所有产品的权限、菜单、用户等。它包含了单点登录、用户管理、RBAC3、第三方平台接入、Ldap等企业级功能。除了可以用在企业内部管理系统,它还可以帮助管理C端用户。
![Auth](http://cdn.masastack.com/stack/doc/auth/introduce.png)
MASA Auth is one of the most central features of the MASA Stack, responsible for permissions, menus, and users across all products. It encompasses single sign-on, user management, RBAC3, third-party platform integration, LDAP, and other enterprise-grade features.

## MASA Stack 概览
[传送门](https://github.com/masastack/MASA.Stack)
## Code of Conduct

## 特性
- 待补充

## 安装
- 待补充


## 本地开发
- 待补充

## 开发路线
- 待补充

## 贡献者

感谢所有为本项目做出过贡献的朋友。

<a href="https://github.com/masastack/MASA.Auth/graphs/contributors">
<img src="https://contrib.rocks/image?repo=masastack/MASA.Auth" />
</a>

## 行为准则

本项目采用了《贡献者公约》所定义的行为准则,以明确我们社区的预期行为。
更多信息请见 [MASA Stack Community Code of Conduct](https://github.com/masastack/community/blob/main/CODE-OF-CONDUCT.md).
Please refer to our [MASA Stack Community Code of Conduct](https://github.com/masastack/community/blob/main/CODE-OF-CONDUCT.md).

3 changes: 3 additions & 0 deletions src/ApiGateways/Masa.Auth.ApiGateways.Caller/AuthCaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class AuthCaller : StackHttpClientCaller
PositionService? _positionService;
OssService? _ossService;
OperationLogService? _operationLogService;
WebhookService? _webhookService;
#endregion

public ThirdPartyIdpService ThirdPartyIdpService => _thirdPartyIdpService ?? (_thirdPartyIdpService = new(Caller));
Expand Down Expand Up @@ -62,6 +63,8 @@ public class AuthCaller : StackHttpClientCaller

public OperationLogService OperationLogService => _operationLogService ?? (_operationLogService = new OperationLogService(Caller));

public WebhookService WebhookService => _webhookService ?? (_webhookService = new WebhookService(Caller));

protected override string BaseAddress { get; set; }

public AuthCaller(AuthApiOptions options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,15 @@ public async Task<ThirdPartyUserDetailDto> GetDetailAsync(Guid id)
{
return await SendAsync<object, ThirdPartyUserDetailDto>(nameof(GetDetailAsync), new { id });
}

public async Task RemoveAsync(Guid id)
{
await DeleteAsync(nameof(RemoveAsync), new { id });
}

public async Task RemoveByThridPartyIdentityAsync(string thridPartyIdentity)
{
await DeleteAsync(nameof(RemoveByThridPartyIdentityAsync), new { thridPartyIdentity });
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

namespace Masa.Auth.ApiGateways.Caller.Services.Webhooks;

public class WebhookService : ServiceBase
{
protected override string BaseUrl { get; set; } = "";

public WebhookService(ICaller caller) : base(caller)
{
BaseUrl = "api/webhook";
}

public async Task<PaginationDto<WebhookItemDto>> GetListAsync(GetWebhookPaginationDto getWebhookPaginationDto)
{
return await GetAsync<GetWebhookPaginationDto, PaginationDto<WebhookItemDto>>("list", getWebhookPaginationDto);
}

public async Task<WebhookDetailDto> GetDetailAsync(Guid id)
{
return await GetAsync<WebhookDetailDto>($"get?id={id}");
}

public async Task SaveAsync(WebhookDetailDto webhookDto)
{
await PostAsync("save", webhookDto);
}

public async Task RemoveAsync(Guid id)
{
await DeleteAsync($"remove?id={id}");
}
}
2 changes: 2 additions & 0 deletions src/ApiGateways/Masa.Auth.ApiGateways.Caller/_Imports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
global using Masa.Auth.ApiGateways.Caller.Services.Projects;
global using Masa.Auth.ApiGateways.Caller.Services.Sso;
global using Masa.Auth.ApiGateways.Caller.Services.Subjects;
global using Masa.Auth.ApiGateways.Caller.Services.Webhooks;
global using Masa.Auth.Contracts.Admin;
global using Masa.Auth.Contracts.Admin.Infrastructure.Constants;
global using Masa.Auth.Contracts.Admin.Infrastructure.Dtos;
Expand All @@ -19,6 +20,7 @@
global using Masa.Auth.Contracts.Admin.Projects;
global using Masa.Auth.Contracts.Admin.Sso;
global using Masa.Auth.Contracts.Admin.Subjects;
global using Masa.Auth.Contracts.Admin.Webhooks;
global using Masa.BuildingBlocks.Service.Caller;
global using Masa.BuildingBlocks.StackSdks.Auth.Contracts;
global using Masa.BuildingBlocks.StackSdks.Auth.Contracts.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public static class CacheKey
const string ACCOUNT_LOGIN_PRE = "account_login:";
const string USER_SYSTEM_DATA_PRE = "user_system_data:";
const string MSG_CODE_FOR_UPDATE_USER_PHONENUMBER = "msg_code_update_user_phoneNumber:";
const string MSG_CODE_FOR_LOGIN = "msg_code_login:";
const string MSG_CODE_FOR_REGISTER = "msg_code_register:";
const string MSG_CODE_REGISTER_LOGIN = "msg_code_register_and_login:";
const string MSG_CODE_FOR_BIND = "msg_code_bind:";
const string MSG_CODE_FOR_VERIFIY_USER_PHONENUMBER = "msg_code_verifiy_user_phoneNumber:";
const string VERIFIY_USER_PHONENUMBER_RESULT = "verifiy_user_phoneNumber_result:";
Expand All @@ -23,7 +22,6 @@ public static class CacheKey
const string EMAIL_BIND_CODE_PRE = "email_bind_code:";
const string EMAIL_BIND_SEND_CODE_PRE = "email_bind_send_code:";
const string EMAIL_REGISTER_SEND_PRE = "email_register_send:";
const string SMS_REGISTER_SEND_PRE = "sms_register_send:";
const string EMAIL_VERIFIY_CODE_PRE = "email_verifiy_code:";
const string EMAIL_VERIFIY_SEND_PRE = "email_verifiy_send:";
const string EMAIL_FORGOT_PASSWORD_CODE_PRE = "email_forgot_password_code:";
Expand All @@ -34,6 +32,7 @@ public static class CacheKey
const string EMAIL_UPDATE_SEND_PRE = "email_update_send:";
public const string STAFF_DEFAULT_PASSWORD = "staff_default_password";
const string MSG_VERIFIY_CODE_SEND_EXPIRED = "msg_verifiy_code_send_expired:";
const string IMPERSONATION_USER= "impersonation_user:";

public static string AllPermissionKey()
{
Expand Down Expand Up @@ -75,26 +74,16 @@ public static string MsgCodeForUpdateUserPhoneNumberKey(string userId, string ph
return $"{MSG_CODE_FOR_UPDATE_USER_PHONENUMBER}{userId}{phoneNumber}";
}

public static string MsgCodeForLoginKey(string userId, string phoneNumber)
public static string MsgCodeRegisterAndLoginKey(string phoneNumber)
{
return $"{MSG_CODE_FOR_LOGIN}{userId}{phoneNumber}";
}

public static string MsgCodeForRegisterKey(string phoneNumber)
{
return $"{MSG_CODE_FOR_REGISTER}{phoneNumber}";
return $"{MSG_CODE_REGISTER_LOGIN}{phoneNumber}";
}

public static string MsgCodeForBindKey(string phoneNumber)
{
return $"{MSG_CODE_FOR_BIND}{phoneNumber}";
}

public static string MsgCodeForRegisterSendKey(string phoneNumber)
{
return $"{SMS_REGISTER_SEND_PRE}{phoneNumber}";
}

public static string EmailCodeRegisterSendKey(string email)
{
return $"{EMAIL_REGISTER_SEND_PRE}{email}";
Expand Down Expand Up @@ -174,4 +163,9 @@ public static string MsgVerifiyCodeSendExpired(string key)
{
return $"{MSG_VERIFIY_CODE_SEND_EXPIRED}{key}";
}

public static string ImpersonationUserKey(string impersonationToken)
{
return $"{IMPERSONATION_USER}{impersonationToken}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class PasswordHelper : ISingletonDependency
public const string PASSWORDRULECONFIGNAME = "$public.AppSettings:PasswordRule";
public const string DEFAULTPASSWORDRULE = "^\\S*(?=\\S{6,})(?=\\S*\\d)(?=\\S*[A-Za-z])\\S*$";

private IMasaConfiguration _masaConfiguration;
private readonly IMasaConfiguration _masaConfiguration;

public PasswordHelper(IMasaConfiguration masaConfiguration)
{
Expand All @@ -35,11 +35,6 @@ public string GetPasswordRule()
{
//ignore
}
finally
{
passwordRule = DEFAULTPASSWORDRULE;
}

}
return passwordRule;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,31 @@ namespace Masa.Auth.Contracts.Admin.Infrastructure.Utils;

public static class ImageSharper
{
public static MemoryStream GeneratePortrait(char show, Color textColor, Color backgroundColor, int size)
static Image<Rgba32> Generate(char show, Color textColor, Color backgroundColor, int size)
{
var ms = new MemoryStream();
using var image = new Image<Rgba32>(size, size);
image.Mutate(x => x.BackgroundColor(backgroundColor));
var textOptions = new TextOptions(new Font(GetFontFamily(), (int)(size * 0.6)))
var textOptions = new RichTextOptions(new Font(GetFontFamily(), (int)(size * 0.6)))
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Origin = new Vector2(size / 2, size / 2)
};
image.Mutate(x => x.DrawText(textOptions, show.ToString(), textColor));
image.SaveAsPng(ms);
return image;
}

public static MemoryStream GeneratePortrait(char show, Color textColor, Color backgroundColor, int size)
{
var ms = new MemoryStream();
using var image = Generate(show, textColor, backgroundColor, size);
ms.Seek(0, SeekOrigin.Begin);
return ms;
}

public static void GeneratePortrait(char show, Color textColor, Color backgroundColor, int size, string path)
{
using var image = new Image<Rgba32>(size, size);
image.Mutate(x => x.BackgroundColor(backgroundColor));
var textOptions = new TextOptions(new Font(GetFontFamily(), (int)(size * 0.6)))
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Origin = new Vector2(size / 2, size / 2)
};
image.Mutate(x => x.DrawText(textOptions, show.ToString(), textColor));
using var image = Generate(show, textColor, backgroundColor, size);
image.SaveAsPng(path);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<PackageReference Include="Masa.Utils.Extensions.Validations.FluentValidation" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta15" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0" />
<PackageReference Include="Util.Reflection" Version="1.0.3" />
<PackageReference Include="Masa.Contrib.StackSdks.Mc" Version="$(MasaFrameworkPackageVersion)" />
<PackageReference Include="Masa.Contrib.StackSdks.Pm" Version="$(MasaFrameworkPackageVersion)" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

namespace Masa.Auth.Contracts.Admin.Permissions;

public class RoleSimpleDetailDto
{
public Guid Id { get; set; }

public string Name { get; set; } = string.Empty;

public string Code { get; set; } = string.Empty;

public bool Enabled { get; set; }

public List<RoleSimpleDetailDto> Children { get; set; } = new();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,12 @@ public class RegisterFieldDto

public bool Required { get; set; }

public bool CannotUpdate { get; private set; }

[JsonConstructor]
public RegisterFieldDto(RegisterFieldTypes registerFieldType, int sort, bool required)
{
RegisterFieldType = registerFieldType;
Sort = sort;
Required = required;
if (RegisterFieldType is RegisterFieldTypes.PhoneNumber)
{
CannotUpdate = true;
}
}
}

Loading

0 comments on commit 7989ae9

Please sign in to comment.