Tuesday, 2025-01-28

opendevreviewKoya Watanabe proposed openstack/keystonemiddleware master: Add cryptography package as a dependency  https://review.opendev.org/c/openstack/keystonemiddleware/+/94027801:58
*** mhen_ is now known as mhen02:07
*** mhen_ is now known as mhen03:05
Ivvehhello, i have a rather odd question to ask. looking into how keystone policy.yaml works and which calls are allowed. im trying to create a form of user that can only call "identity:create_project" but i am unable to do so. so i am wondering if there is some special sauce im missing. the only way i can create projects is with admin role and system all scope. even with the default manager role a user i create is unable to cr14:38
gtemaIvveh: you should create a new dedicated role and extend the policy check for `create_project`to respect this role14:40
Ivvehso i added manager role to a user, linked to a project and also added the same role (manager) to scope system all but the default policy.yaml says "identity:create_project": "(rule:admin_required) or (role:manager and domain_id:%(target.project.domain_id)s)". but no cigar14:41
gtemabut the manager role (when authzed in the domain scope) is giving you this already14:41
Ivvehhmmmmmm14:41
Ivvehso what i did should work?14:41
Ivveh(the manager role stuff)14:41
gtemagetting token in the domain scope - yes14:42
Ivvehso, just to be perfectly clear here are the commands that should give the user the correct permission(as admin): openstack role add --domain default --user myuser manager ; openstack role add --system all --user myuser manager (?)14:44
gtemayou do not need to mess system scope - it is anyway wrong for a regular user 14:45
Ivvehthis will create two assignments which should give me manager for domain default and manager in scope all?14:45
gtemarole creation is also tricky. Thechnically you have already manager role as part of the standard openstack roles14:46
gtemaand it is a global role, not the domain bound14:46
gtemaso instead it should be 'openstack role add --domain <DOMAIN> --user <USER> manager'14:47
Ivvehso i need to create another role with the name manager?14:47
gtemanames must be unique14:48
gtemayou just grant existing global role in the domain scope to the user14:48
Ivvehso i wrote two commands, the second one should be omitted. but this is the result: ou are not authorized to perform the requested action: identity:create_project.14:48
Ivvehso frustrating.. 14:49
Ivvehopenstack role add --domain default --user myuser manager14:49
gtemabut well - this user gets more permissions - grant roles to users in that domain, so if you ONLY want to have user permissions to created new projects (and i.e. not delete) - you should create new global role and extend policy to for the create_project to respect new role (same as it is doing now for manager)14:49
Ivvehjust trying to understand this particular rule which is a little out of the ordinary14:50
gtemaand do not forget - this check is explicitly verifying that your token is in the domain scope and not project scope14:51
Ivvehthe policy.yaml check?14:51
gtemadomain_id:%(target.project.domain_id) means that the token with the domain scope on domain X must match the domain in which the project should be created14:51
gtemaoh, actually it may work in project scope as well14:52
Ivvehthat the project im trying to create is being created in "default" according to what im trying to do?14:52
Ivvehor what type of token is issued to my client "myuser" ? :D14:53
Ivvehor rather, if the token he has was issued in the correct scope?14:53
gtemafor most of things you do in keystone token scope is very important14:54
gtemauser should be authorizing in the domain_scope14:54
Ivvehso the token must be issued correctly first, yeah. that is quite complex on how it works14:54
Ivvehim just used to working with 1 domain and regular roles in projects14:55
Ivvehbut this creating projects in a domain, i dont understand14:55
Ivvehso when "myuser" is issuing a token, if i pass too much or too little it will deny the project create request, is this correct?14:56
gtemaneed to correct myself, 'domain_id:%(target.project.domain_id)' means project can be only created in the domain which the user belong to14:56
gtemaevery project belong to certain domain, the same as users14:57
gtemaif you do not 'use' domains most likely it is implicitly the 'default' domain14:58
Ivvehthats what i understood from docs.. i also tried to modify the rule in policy.yaml and make it superbasic. i created a role called "manage" (without r) just to try but got deprecation warnings so i was unsure if it worked (the policy.yaml was functioning) but i still couldn't create projects no matter what14:58
Ivvehlike: "identity:create_project": "(rule:manage)"14:58
Ivvehadded the role in default domain to user, but no cigar14:59
gtemarule:manage is wrong because it refers to the "rule" and not "role"14:59
Ivvehsorry typo from me14:59
Ivvehor wait!14:59
Ivvehlet me try again15:00
gtemaif you have access to keystone logs you show have something like: `RBAC: auth_context: {'token': <TokenModel (audit_id=WQ0SZeRkRMWUbxx2egB1TA, audit_chain_id=['...']) at 0x11c390110>, 'domain_id': None, 'trust_id': None, 'trustor_id': None, 'trustee_id': None, 'domain_name': None, 'group_ids': [], 'user_id': '...', 'user_domain_id': 'default', 'system_scope': None, 'project_id': '...', 'project_domain_id': 'default', 'roles': ['admin',15:00
gtema'manager', 'reader', 'member'], 'is_admin_project': True, 'service_user_id': None, 'service_user_domain_id': None, 'service_project_id': None, 'service_project_domain_id': None, 'service_roles': []}`15:00
Ivvehnow it looks like this: "identity:create_project": "(rule:admin_required) or (role:manager and domain_id:%(target.project.domain_id)s)"15:01
Ivvehwhen should this log occur?15:01
gtemadrop the 'domain_id:%(target.project.domain_id)s' just to check whether it works for you then15:01
Ivvehgotcha15:02
Ivvehdropping it15:02
gtemawhen the API request is received15:02
Ivvehits like this now15:02
Ivveh"identity:create_project": "(rule:admin_required) or (role:manager)"15:02
Ivvehshould that auth_context pop even during a fail?15:06
gtemayes15:06
gtemaunder assumption that the request reaches keystone15:06
Ivvehdoesnt happen15:06
Ivvehhmm requires authentication error though15:07
gtemado you see any log entries added when you send request`15:07
gtema?15:07
Ivvehdebug is on so kinda limiting stuff by grep15:08
Ivvehwell, getting errors on user not having access to projects15:09
Ivvehim gonna try to remove some exports for the projects15:11
Ivvehafter unsetting all the stuff for projects i just get The service catalog is empty, this is something that i struggled with before and i dont understand it fully15:12
gtemabecause you haven't bootstrapped you keystone fully (most likely)15:13
Ivvehthe token issue doesn't have domain15:13
Ivvehresourceing admin or any other user works15:13
Ivvehthis happend after the role was stripped btw15:16
Ivveh(the admin roles it had)15:16
Ivvehjust testing and debugging a lot but yea15:16
Ivvehi understand that the token needs to match the permissions but i can't get that puzzle to match for this particular role (to create projects)15:17
Ivvehokay if i send --os-domain-name parameter it works. but the export doesn't... great15:18
Ivveh(catalog list)15:18
opendevreviewMerged openstack/oslo.policy master: Skip cross jobs for non-functional update  https://review.opendev.org/c/openstack/oslo.policy/+/94021315:20
Ivvehalright alright15:21
Ivvehits about the token and the parameters sent in for the requests thats probably wrong15:21
Ivvehjeez its sensitive :D15:21
Ivvehfuck, yea15:22
Ivvehit works now...15:22
gtemaif you are not working with clouds.yaml and still use ENV or args (which you should stop asap) passing project_id/project_name causes the token to be in the project scope. If you set the domain_id/name token will be in the domain_Scope15:22
gtemaand so the removed policy rule part is requiring that user must be using domain scope token which is only possible if he is explicitly granted this role on this domain15:23
gtemaotherwise anyone is able to create projects everywhere15:23
Ivvehyeah thats true, its just a dev env atm so just went with env15:29
Ivvehthe role was added in domain scope though15:29
Ivvehbut the poicy doesnt require it15:30
Ivvehill fiddle around a bit15:30
gtemaif you return domain_id:%(target.project.domain_id)s back (what you SHOULD do) it will require that role is granted on the domain for which user can get token15:31
Ivvehwhich it is, so changing the rule back should work15:31
Ivveh(out of the box)15:31
gtemayes15:31
Ivvehhmm it doesnt15:33
Ivvehmaybe i tried this before15:33
Ivvehdont wanna paste the assignment output but, basically rule -> user -> domain(default) -> inherit false15:34
Ivvehuhm, *role15:34
gtemayes15:34
Ivvehso im guessing i must pass other args now15:36
Ivvehbut dont know which ones15:36
gtemano project, only domain-id (or domain-name)15:36
Ivvehno cigar15:38
Ivvehpassed both, or one each15:38
Ivvehtried the id/name (default and Default)15:38
gtemaI have no clue what "no cigar" means. You pass either domain-id or domain-name15:38
Ivvehit says it should be case-insentsitive but i dont trust it15:39
gtemanot even sure which call you mean15:39
Ivvehopenstack project create manager-created-project   --os-auth-url http://1.2.3.4:5000/v3/   --os-username user  --os-password password      --os-auth-type password  [ --os-domain-id default | --os-domain-name Default ]15:40
Ivvehtried both options, both give same auth problem15:40
Ivveh(no cigar basically means it didn't work)15:41
IvvehYou are not authorized to perform the requested action: identity:create_project.15:41
Ivvehit actually is sensitive on the D or d15:42
Ivvehbut docs state that it isnt..15:42
IvvehThe request you have made requires authentication. if the D/d is incorrect15:43
gtemaI have seen installations where "domain_id: default" = "domain_name: Default"15:43
Ivvehthe role was added likeso: openstack role add --user user --domain Default manager15:44
Ivvehand the rule that worked was: identity:create_project": "(rule:admin_required) or (role:manager)"15:44
Ivvehafter the and domain_id:%(target.project.domain_id)s) was added, it stopped allowing it15:45
Ivveh(the rule add and project create command unchanged)15:45
gtemamost likely because you do not use the right token15:45
Ivvehill try with clouds.yaml method15:46
Ivvehwhat im looking for is the http/s api call in the end15:46
Ivvehbut should it be and domain_id:%(target.project.domain_id)s)15:46
Ivvehtarget.PROJECT.domain_id?15:47
gtemayes, the project (to be created) must belong to the domain in which user has the role and authed in domain scope15:48
Ivvehperhaps i need the role assigned to a project that needs to be in the correct domain, or both?15:48
Ivvehhmmm15:49
Ivvehare you sure?15:51
Ivvehif feels like too much info, the api already knows that im creating a project, why does the target need to state the project again.. looking at other roles they can be like15:52
Ivvehdomain_id:%(target.user.domain_id)s), user_id:%(target.user.id)s15:53
gtemabecause you MUST check whether user has rights in the target scope which is at the moment only possible when the user is authenticated in the target scope (here target domain is meant and not the target project which doesn't exist yet)15:53
Ivvehah15:54
Ivvehgotcha15:54
gtemaevery operation has different purpose and security protections15:54
Ivvehmy token give me 4 fields, user_id, domain_id, id (the token) and expire15:55
Ivvehand the role was added as above and the policy is also as above15:56
Ivvehi mean i can solve this by creating a separate role at this point, i just wanna understand the client for debugging reasons15:58
gtemaopenstack client has a very useful flag "--debug" which prints out all API calls (except the auth itself)15:59
Ivvehyeah but for that i need a success :D16:00
Ivvehim using that to figure out how the api call should look like (when its working)16:01
gtemaplease summarize you current conditions16:01
Ivvehafter setting the role to default domain to the user and having the correct role in policy.yaml (restricting manger role and domain default) i want openstack project create manager-created-project   --os-auth-url http://1.2.3.4:5000/v3/   --os-username user  --os-password password      --os-auth-type password  [ --os-domain-id default | --os-domain-name Default ]  --debug to show me the correct call to auth+create project 16:03
Ivvehremoving the domain_id:%(target.project.domain_id)s)  from the policy,yaml yield a success16:04
Ivvehhaving it there doesn't16:04
gtemawhat is in the keystone log (auth context)16:04
IvvehRBAC: auth_context: {'token': <TokenModel (audit_id=yz6yBytARHyLgjI5bOoXpg, audit_chain_id=['yz6yBytARHyLgjI5bOoXpg']) at 0x7fb5bc357860>, 'domain_id': 'default', 'trust_id': None, 'trustor_id': None, 'trustee_id': None, 'domain_name': 'Default', 'group_ids': [], 'user_id': '9a7459b521d24e879bd6cb8dd36594f0', 'user_domain_id': 'default', 'system_scope': None, 'project_id': None, 'project_domain_id': None, 'roles': ['manage16:06
gtemaand eventually your client call misses "--domain default" (as the domain in which the project should be created). The "--os-domain-..." describes you authroization16:06
Ivvehis it project_domain_id?16:07
Ivvehthat is None, should have default as value?16:08
gtemait is the domain in which the project should be created16:08
Ivveha successful call has this field with "default"16:08
Ivveh'project_domain_id': 'default',16:08
gtemaand if it is None then it doesn't match the check in the policy which enforces that domain_id (or the current auth) = target.project.domain_id16:09
Ivvehi guess i can find this in enforce.py?16:09
Ivveh(if i want to take a closer look)16:09
gtemanot really. In the enforcer.py you may add print with the "target" in the "_enforce" method16:10
gtemacause in the keystone log you only have auth_context but not the target16:11
Ivvehaha16:12
Ivvehcould i technically create a role replacing target.project.domain_id with an actual value in policy.yaml?16:13
Ivvehmaking the role only work in a certain domain, or replace domain with project or user or whatever other resource that can take roles?16:13
gtemathat is exactly why you grant a role to user on a project (or domain)16:13
Ivvehokay gtema thanks a lot for the patience and help/info16:21
gtemawelcome16:21
*** priteau is now known as Guest726717:04
*** priteau2 is now known as priteau17:04
opendevreviewOria Weng proposed openstack/keystone master: Add JSON schema & validation for `role assignment`  https://review.opendev.org/c/openstack/keystone/+/94034422:01
opendevreviewOria Weng proposed openstack/keystone master: Add JSON schema & validation for `role assignment`  https://review.opendev.org/c/openstack/keystone/+/94034423:13

Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!