cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

api: project: tag: User not allowed to tag project created by him

Open resmo opened this issue 8 years ago • 1 comments

ISSUE TYPE
  • Bug Report
COMPONENT NAME
API
CLOUDSTACK VERSION
4.11.1
4.5.2
CONFIGURATION

N/A

OS / ENVIRONMENT

N/A

SUMMARY
STEPS TO REPRODUCE

in the UI:

  • log in as a user type
  • create a project
  • tag the new created project

also reproducible by ansible

- name: create smoke project
  cs_project:
    name: smoke
    tags:
      - { key: smoke, value: test }
EXPECTED RESULTS
tags get created
ERROR [c.c.a.ApiAsyncJobDispatcher] (API-Job-Executor-24:ctx-4d3d27e8 job-52) (logid:e3feed0a) Unexpected exception while executing org.apache.cloudstack.api.command.user.tag.CreateTagsCmd
com.cloud.exception.PermissionDeniedException: Acct[d5a76f5a-0756-441f-a9b2-c970856e2fff-smoke account] does not have permission to operate with resource Acct[8285648a-a84e-11e8-b2c2-0242ac110002-system]
	at com.cloud.acl.DomainChecker.checkAccess(DomainChecker.java:154)
	at com.cloud.acl.DomainChecker.checkAccess(DomainChecker.java:351)
	at com.cloud.user.AccountManagerImpl.checkAccess(AccountManagerImpl.java:555)
	at com.cloud.user.AccountManagerImpl.checkAccess(AccountManagerImpl.java:504)
	at sun.reflect.GeneratedMethodAccessor302.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:338)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
	at com.sun.proxy.$Proxy118.checkAccess(Unknown Source)
	at com.cloud.tags.TaggedResourceManagerImpl.checkResourceAccessible(TaggedResourceManagerImpl.java:243)
	at com.cloud.tags.TaggedResourceManagerImpl.access$100(TaggedResourceManagerImpl.java:95)
	at com.cloud.tags.TaggedResourceManagerImpl$1.doInTransactionWithoutResult(TaggedResourceManagerImpl.java:303)
	at com.cloud.utils.db.TransactionCallbackNoReturn.doInTransaction(TransactionCallbackNoReturn.java:25)
	at com.cloud.utils.db.Transaction$2.doInTransaction(Transaction.java:50)
	at com.cloud.utils.db.Transaction.execute(Transaction.java:40)
	at com.cloud.utils.db.Transaction.execute(Transaction.java:47)
	at com.cloud.tags.TaggedResourceManagerImpl.createTags(TaggedResourceManagerImpl.java:287)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:338)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.apache.cloudstack.network.contrail.management.EventUtils$EventInterceptor.invoke(EventUtils.java:107)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:174)
	at com.cloud.event.ActionEventInterceptor.invoke(ActionEventInterceptor.java:51)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:174)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
	at com.sun.proxy.$Proxy306.createTags(Unknown Source)
	at org.apache.cloudstack.api.command.user.tag.CreateTagsCmd.execute(CreateTagsCmd.java:117)
	at com.cloud.api.ApiDispatcher.dispatch(ApiDispatcher.java:150)
	at com.cloud.api.ApiAsyncJobDispatcher.runJob(ApiAsyncJobDispatcher.java:108)
	at org.apache.cloudstack.framework.jobs.impl.AsyncJobManagerImpl$5.runInContext(AsyncJobManagerImpl.java:581)
	at org.apache.cloudstack.managed.context.ManagedContextRunnable$1.run(ManagedContextRunnable.java:49)
	at org.apache.cloudstack.managed.context.impl.DefaultManagedContext$1.call(DefaultManagedContext.java:56)
	at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(DefaultManagedContext.java:103)
	at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(DefaultManagedContext.java:53)
	at org.apache.cloudstack.managed.context.ManagedContextRunnable.run(ManagedContextRunnable.java:46)
	at org.apache.cloudstack.framework.jobs.impl.AsyncJobManagerImpl$5.run(AsyncJobManagerImpl.java:529)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
ACTUAL RESULTS
tagging fails

resmo avatar Aug 27 '18 16:08 resmo

Permission is denied because when tagging we attempt to check for permissions - which is as follows -

  1. Check if the entity is owned by some account id - represented by implemented OwnedBy interface.
  2. If it's not owned by an account id, it's considered to be owned by System and users cannot tag the resource.

We can possibly extend Projects start tracking by a user and possibly better extend current logic to -

  1. Check if account trying to tag is either admin or
  2. the user who created the Project.

The issue is we don't have definitive way to track the users who created already existing projects.

thoughts @rhtyd , @resmo , @rafaelweingartner , @PaulAngus , @GabrielBrascher ?

anuragaw avatar May 02 '19 09:05 anuragaw