Comments (4)
针对你遇到的问题,由于MySQL中的LIKE查询将下划线(_
)视为任意单个字符的通配符,这就导致了权限异常的问题。为了解决这个问题,你需要在查询中转义下划线。在MySQL中,可以通过在下划线前加上反斜杠(\
)来转义特殊字符。例如:
SELECT * FROM YourTable WHERE YourColumn LIKE 'your\_pattern' ESCAPE '\';
如果你的应用程序动态构建查询,并且需要转义用户输入,那么在将输入字符串包含到查询中之前,你需要在程序中将每个下划线(_
)替换为(\\_
)。
以Python为例,可以这样做:
user_input = "example_app_id" # 假设这是需要包含在LIKE模式中的输入
escaped_input = user_input.replace("_", "\\_")
query = f"SELECT * FROM App WHERE AppId LIKE '{escaped_input}' ESCAPE '\\';"
关于删除后的AppID权限异常并无法恢复的问题,你提到的Apollo仓库代码中并没有处理恢复已删除AppID的逻辑。删除操作通过更新IsDeleted
标志为true来标记appId
为已删除。要恢复,需要一个将IsDeleted
重新设置为false的方法,这在提供的代码中是不存在的。
希望这能帮到你!如果还有其他问题,随时提问。
Details
Sources
- scripts/sql/profiles/mysql-database-not-specified/apolloconfigdb.sql
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/AppRepository.java
- apollo-adminservice/src/test/java/com/ctrip/framework/apollo/adminservice/controller/AppControllerTest.java
- apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/InputValidator.java
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.
from apollo.
To address the issue with AppID permissions after deleting an app with an underscore in its ID, and the subsequent problem with similar AppIDs like hello_world
and helloaworld
, you'll need to ensure that underscores are correctly handled in your SQL queries. This is crucial because MySQL treats underscores as wildcards in LIKE
queries.
First, when performing queries that involve AppIDs with underscores, make sure to escape the underscore. This prevents MySQL from interpreting it as a wildcard. For example, to search for an AppID hello_world
, your query should escape the underscore like this:
SELECT * FROM App WHERE AppId LIKE 'hello\\_world';
This ensures that MySQL searches for the exact AppID, including the underscore, rather than treating the underscore as a wildcard.
If you're dynamically generating these queries based on user input, you'll need to replace underscores in the input with \\_
before including them in the query. Here's how you could do it in Python:
user_input = "hello_world" # The AppID to search for
escaped_input = user_input.replace("_", "\\_")
query = f"SELECT * FROM App WHERE AppId LIKE '{escaped_input}' ESCAPE '\\';"
Regarding the issue of permissions not being restored correctly for helloaworld
after hello_world
has been deleted, it's important to directly address the permission mappings in your database. Ensure that any operation that deletes or modifies AppIDs also correctly updates the permissions associated with those AppIDs. This might involve more complex SQL operations to identify and correct mismatches in permissions caused by the deletion or modification of AppIDs.
Remember, the key to resolving these issues is careful handling of special characters like underscores in SQL queries and ensuring that your application's logic correctly manages the relationships between AppIDs and their associated permissions.
Details
Sources
- scripts/sql/profiles/mysql-default/apolloconfigdb.sql
- scripts/sql/src/apolloportaldb.sql
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PermissionController.java
- apollo-portal/src/main/resources/static/scripts/controller/role/SystemRoleController.js
- apollo-portal/src/main/resources/static/scripts/services/PermissionService.js
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PermissionValidator.java
- apollo-common/src/main/java/com/ctrip/framework/apollo/common/dto/AppDTO.java
- apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/InputValidator.java
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.
from apollo.
当我从Apollo管理页面中删除AppID为hello_world 的应用后,因为下换线的原因,helloaworld 这个应用的权限出现了异常,重新给helloaworld出现异常的人员再次授权,仍无法使用
from apollo.
当我从Apollo管理页面中删除AppID为hello_world 的应用后,因为下换线的原因,helloaworld 这个应用的权限出现了异常,重新给helloaworld出现异常的人员再次授权,仍无法使用
可以尝试手动恢复一下被删除的数据,如
select * from Role where RoleName in ('ModifyNamespace+helloaworld+application', 'ReleaseNamespace+helloaworld+application');
select * from Permission where TargetId = 'helloaworld+application';
from apollo.
Related Issues (20)
- Portal 模块 RestTemplate 支持配置 ConnectionTimeToLive
- apollo2.1.0集成pgsql,求给一份pgsql的sql文件。mysql的不可以用 HOT 4
- 无法删除旧的配置 HOT 7
- 在项目namespace数量比较多的情况下(大约1000个),打开页面加载速度很慢,比较影响用户体验,这个是否有什么优化改进方案? HOT 7
- Apollo是否可以支持按照key维度来发布? HOT 3
- 1.8.0,接入一个app.id 使用多个namespace的时候,多个namesapce均开启了accesskey.sercet,这时候接入的配置代码要怎么写呢 HOT 3
- OidcLocalUserService throw an Exception when executing createLocalUser in OIDC profile HOT 6
- 麻烦问下,有什么办法能同时读到多个环境同一个配置的值吗? HOT 3
- 使用客户端添加string类型的配置项时会报错 HOT 1
- 配置从 2.1.0导出,导入到 2.2.0,数据中时间解析失败 HOT 1
- 在 apollo-portal统一增加访问路径的前缀/apollo 时,导入配置的请求url 有部分没有添加前缀 HOT 1
- apollo-portal 使用统一前缀/apollo以后,创建集群失败 HOT 1
- k8s部署apollo 接入ldap报错 HOT 1
- 请问有大佬已经在2.2.0版本上,数据源由mysql切换至pg了嘛? HOT 1
- 脚本启动与停止的问题 HOT 3
- dockerfile基础镜像漏洞 HOT 4
- 使用docker安装apollo 镜像里面的demo.sh缺少读取环境变量的逻辑 HOT 2
- yml读取k-v的值错误 HOT 2
- Beautify Portal TraceLog UI interface
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo.