apollo
apollo copied to clipboard
Open Api support get authorized apps, namespaces
Is your feature request related to a problem? Please describe.
Use method com.ctrip.framework.apollo.openapi.client.ApolloOpenApiClient#getAllApps
can get all apps.
But there are some app my open api token has no authority to access, and open api will meet exception when try to access them.
If someone just want to get the apps or namespaces authoried,
are there any way to satisfy that?
Describe the solution you'd like
Some new method in com.ctrip.framework.apollo.openapi.client.ApolloOpenApiClient
Like getAuthorizedApps
, getAuthorizedNamespacesByApp
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.
Like
getAuthorizedApps
,getAuthorizedNamespacesByApp
These methods should have params, could you give the full method signature?
Like
getAuthorizedApps
,getAuthorizedNamespacesByApp
These methods should have params, could you give the full method signature?
public List<OpenAppDTO> getAuthorizedApps();
public List<OpenNamespaceDTO> getAuthorizedNamespaces(String appId, String env, String clusterName);
LGTM
LGTM
analysis
Open api's request contains a token
Through portal's database table and E-R Diagram in https://ctripcorp.github.io/apollo/#/zh/design/apollo-design
We can find column by table like follow
square node is column, edge is table
graph TD
Token -->|ConsumerToken|ConsumerId
ConsumerId -->|ConsumerRole|RoleId
RoleId -->|Role|RoleName
RoleId -->|RolePermission|PermissionId
PermissionId -->|Permission|PermissionType
PermissionId -->|Permission|TargetId
The key information is RoleName, PermissionType, TargetId
RoleName
Example:
ModifyNamespace+test+012345678901234567890123456789+DEV
ReleaseNamespace+PT3.sentinel.dashboard+custom
ManageAppMaster+test
Is there a Jave method to parse it?
We can use those information to implement public List<OpenAppDTO> getAuthorizedApps();
?
PermissionType and TargetId
Example
PermissionType | TargetId |
---|---|
ReleaseNamespace | agent+application+DEV |
CreateNamespace | 123456 |
CreateCluster | agent |
It is complex.
We can use those information to implement public List<OpenNamespaceDTO> getAuthorizedNamespaces(String appId, String env, String clusterName);
or other more complex query of authorization?
Meet same problem like above, Is there a Jave method to parse it?
@nobodyiam @nisiyong
I think we may follow the similar logic of com.ctrip.framework.apollo.portal.controller.AppController#findAppsByOwner
https://github.com/ctripcorp/apollo/blob/de05540e6c9a18cdf370ae95ca5e544d7b8d04bf/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java#L91-L106