Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Keystone auth #615

Merged
merged 17 commits into from
Aug 19, 2016
Merged

Keystone auth #615

merged 17 commits into from
Aug 19, 2016

Conversation

zenhack
Copy link
Contributor

@zenhack zenhack commented Jun 10, 2016

WIP. Most of the effort on this one is going to be testing; yay openstack. I'm in the midst of debugging the CI setup. Would appreciate comments on the design, in particular the direction I'm going with the tests.

I'd hoped to work on this more today, but I've been running around doing last minitue prep for something that I half-forgot was this weekend. I'm going to be busy Monday too, but wil dive back into this as soon as I can. possible I can put a bit of time in Sunday night.

//cc @gsilvis, @henn, @knikolla

@zenhack
Copy link
Contributor Author

zenhack commented Jun 10, 2016

(It will probably be easier for everyone if you guys look at this before I've nailed down every last thing and am just blocked on review).

@@ -70,7 +70,7 @@ def _get_readme():
'importlib==1.0.3',
'passlib==1.6.2',
'pexpect==3.3',
'requests==2.4.1',
'requests>=2.4.1,<3.0',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does requests 3.0 break something? If so, a comment mentioning that could help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't exist yet, but see http://semver.org/

Maybe worth having a comment about that in general.

for key in cfg.options(__name__):
keystone_cfg[key] = cfg.get(__name__, key)

# Great job with the API design Openstack! </sarcasm>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

factories!!!!

@gsilvis
Copy link
Contributor

gsilvis commented Jun 15, 2016

Hm. I'm not sure tests running against a real Keystone should be considered unit tests. What I would do for unit tests is: fake the Keystone calls, make sure that it determines authorization correctly, for a few different kinds of calls. Then, save the actual running against Keystone for integration tests.

@zenhack
Copy link
Contributor Author

zenhack commented Jun 15, 2016

Yeah, it's in the wrong directory. Will fix

@zenhack zenhack force-pushed the keystone-auth branch 2 times, most recently from 6fad9d0 to 2239bfa Compare June 15, 2016 20:36
@zenhack
Copy link
Contributor Author

zenhack commented Jun 15, 2016

@gsilvis, it's been moved. I rebased; trying to not pollute the history too much. Perhaps useful for mitigating the negative effects of that:

https://zenhack.net/2015/09/27/github-code-review-workflow.html

@gsilvis
Copy link
Contributor

gsilvis commented Jun 22, 2016

49caef5 looks good to me

@henn
Copy link
Contributor

henn commented Jun 22, 2016

Probably already on your radar, but would it be possible to include some documentation that talks about where projects get created and roles get assigned under keystone? (ie - is it in HIL or keystone; does it require being a HIL || keystone admin, etc)

@zenhack
Copy link
Contributor Author

zenhack commented Jun 22, 2016

@henn: @gsilvis, @knikolla and I talked about this on IRC for a while. I'm not 100% sure we actually came to an agreement, but I think the plan for the time being is to match projects up by name; an admin will have to create a project in hil corresponding to the openstack project name, and then you can authenticate with keystone.

@gsilvis, @knikolla, did I forget anything important from that conversation?

@zenhack
Copy link
Contributor Author

zenhack commented Jun 22, 2016

Of course whatever gets implemented will be clearly documented.

@henn
Copy link
Contributor

henn commented Jun 22, 2016

@zenhack, @gsilvis, @knikolla - is that how it works in other OpenStack projects, like Nova or Cinder? I'd be interested in documenting somewhere (maybe here?) the pros/cons for the different possibilities.

Also - If we implemented quotas (not sure if keystone stores that or the service?), all OpenStack projects could be referenced without being created in HIL first, but just the ones with HIL quotas would be able to do anything more than query stuff.

@zenhack
Copy link
Contributor Author

zenhack commented Jun 22, 2016

We're logging the IRC channel, correct? Could we fish out the logs for that conversation, rather than having it again? I don't know where those are.

@zenhack
Copy link
Contributor Author

zenhack commented Jun 22, 2016

@kamfonik, I remember you spending a bunch of time rigging up an irc logger; can you maybe fish out some logs for us? I think it was the same day that #616 got submitted/merged.

@zenhack
Copy link
Contributor Author

zenhack commented Jun 22, 2016

Or perhaps #614; not sure.

@kamfonik
Copy link

moc.2016-06-09.log.txt
I think this is the one you want? The other day had no conversation.

@kamfonik
Copy link

@zenhack If that's not the right one let me know, I can zip up all the logs from June for you

@zenhack
Copy link
Contributor Author

zenhack commented Jun 22, 2016

hm, I remember a longer discussion about how to do the project mapping, but apparently it didn't happen when I thought. @gsilvis, @knikolla: do you remember when that was? @henn, you said you thought you had something in your buffer that seemed relevant, when was that?

(as an aside, might be better if we could just access this ourselves in the future...)

@zenhack
Copy link
Contributor Author

zenhack commented Jun 22, 2016

Getting the whole month's logs might just be the easy thing to do.

@zenhack
Copy link
Contributor Author

zenhack commented Jun 23, 2016

Here are the relevant bits of the conversation that @gsilvis, @knikolla and I had on IRC:

https://gist.github.com/zenhack/5ea1b615681f43c14718a2a6e8e8629e

This was interleaved with discussion about what became #614. I've removed what clearly isn't relevant, but the topics overlapped in places.

@kamfonik, thanks for digging these out.

@zenhack
Copy link
Contributor Author

zenhack commented Jun 24, 2016

@henn, if you would read over that log and then weigh in, that would be appreciated.

@gsilvis, @knikolla, let's come to a consensus on this so I can plow ahead.

Also: regretably this hasn't gone in quite as quickly as I'd hoped. Most of that is to do with me; I've been dealing with sleep debt, and other commitments which I did a poor job of planning around. A thing to be aware of is that I'm going to be unavailable (and unable to work on this) starting Tuesday of next week through July 4th. Getting this in before then is going to be tight, but we come to a consensus on these issues tomorrow, I can probably have something working and ready for review by Monday. If we don't get it in before then it will have to wait another week.

@zenhack
Copy link
Contributor Author

zenhack commented Jul 10, 2016

Folks, can we come to a consensus on this?

@zenhack
Copy link
Contributor Author

zenhack commented Jul 13, 2016

Since it's perhaps easier than rifling through the IRC log, here's a summary of the questions at hand, and proposed solutions:

  1. How do we map Openstack projects to HIL projects?
    1. Proposal: map HIL project name to Openstack project name.
      • Advantages:
        • Easy to work with from a UI perspective.
      • Disadvantages:
        • Openstack project names are only unique per domain. As discussed on
          IRC, one solution would be to specify the domain that HIL uses in the
          config file (which would restrict us to only one).
    2. Proposal: map HIL project name/label to Openstack project UUID
      • Advantages:
        • Globally unique
        • Corresponds to how openstack identifies resources generally.
      • Disadvantages:
        • Identifiers are opaque; would have to separately look up UUID to get
          human-understandable notion of what project we're talking about.
  2. How does HIL learn about new Openstack projects?
    1. Proposal: Administrator must manually create a project in HIL with the
      identifier that corresponds to the Openstack project in question.
      • Advantages:
        • Simple
        • More administrative control over who has access to HIL.
      • Disadvantages:
        • Requires more work for administrators
    2. Proposal: When HIL sees a valid token for a project it doesn't know about,
      it creates the project on the fly.
      • Advantages:
        • Less work for administrators
        • Less bookkeeping in the overall system
      • Disadvantages:
        • Less administrative control
        • More complex implementation
        • Arguably inconsistent with the rest of the HIL api, which is very manual.
          • Note that the general philosophy of building higher-level tools suggests
            users who want this should just have a tool that creates both Openstack
            and HIL projects at the same time. Users who want (1) can't as easily
            simulate it if we choose (2).

My preferences are to map projects to UUIDs, and do manual project creation,
but I don't feel super strongly (especially about the second issue).

@gsilvis has expressed that he strongly prefers manual project creation.

The IRC thread also discussed some database schema changes re: the
existence of the project table, but if nothing else, they strike me as entirely
orthoginal to the keystone work, and I'd rather leave them out of the present
discussion. @knikolla, if you feel strongly to the contrary feel free to make a
case.

//cc @henn

@zenhack
Copy link
Contributor Author

zenhack commented Jul 13, 2016

Re: UI issues around using UUIDs for projects: we can always write tools that look up projects by name before invoking the API, so the user doesn't have to deal with it. General philosophy has been to keep the server-side fairly dumb.

@okrieg
Copy link
Contributor

okrieg commented Jul 13, 2016

I like the idea of manual project creation and mapping projects to UUIDs

I am less clear about the domain issue for project names.

is there problems with the uglyness of having huge UUIds in the project name of HIL, not obvious why/if this is a problem?

@zenhack
Copy link
Contributor Author

zenhack commented Aug 4, 2016

I believe I've either implemented or replied to all comments; let me know if I missed something. travis is still running at the moment, but stuff passes on my local machine.

@knikolla
Copy link
Contributor

knikolla commented Aug 8, 2016

Looks good to me, +1.

@gsilvis
Copy link
Contributor

gsilvis commented Aug 8, 2016

This still all looks good to me. @henn had more requests than I did, so I think it'd be good for him to give this his +2.

@zenhack
Copy link
Contributor Author

zenhack commented Aug 8, 2016

Added the docs re: admin role and a thing to test against mitaka.

To grant the Openstack project with that UUID access to HaaS.

Note that the plugin recognizes any user with an `admin` role on any
project as a HaaS administrator, similar to the default policy for core
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you say as a global HaaS administrator, able to administrate all projects,

Copy link
Contributor Author

@zenhack zenhack Aug 10, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clarification was for keystone folks, where you could have a project
admin vs. a global admin.

Copy link
Contributor Author

@zenhack zenhack Aug 10, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That just isn't true. In both Openstack and haas, 'admin' refers to a global admin (or at least the admin of a domain), and there is no concept of a project admin.

@henn
Copy link
Contributor

henn commented Aug 9, 2016

re: the test failures, it looks like keystone's tools/sample_data.sh changed somewhat between stable/mitaka and now.

Perhaps using tag 10.0.0.0b2 instead of stable/mitaka would be a good workaround?

@zenhack
Copy link
Contributor Author

zenhack commented Aug 10, 2016

Quoting Jason Hennessey (2016-08-09 03:40:29)

re: the test failures, it looks like keystone's tools/sample_data.sh
changed somewhat between stable/mitaka and now.

Perhaps using tag 10.0.0.0b2 instead of stable/mitaka would be a
good workaround?

Not a bad idea. I will fuss with it and find a version that works.

mitaka doesn't seem to work; @henn suggested this tag instead.
@henn
Copy link
Contributor

henn commented Aug 16, 2016

One final question - what is the error given back to the user if the keystone client credentials are incorrect in some way (username, password, inaccessible project, etc)?

@henn
Copy link
Contributor

henn commented Aug 18, 2016

@zenhack - Just wanted to check that the error was something sane.

@zenhack
Copy link
Contributor Author

zenhack commented Aug 19, 2016

@henn, sorry for the delay. I poked at it a bit, most mistakes give you a 401. You get a connection error from keystone if OS_AUTH_URL is wrong

@zenhack
Copy link
Contributor Author

zenhack commented Aug 19, 2016

Also, a piece of this that I'd meant to deal with at some point, but that got forgotten about: how do we bootstrap the list of projects? We could add another command like create_initial_admin or whatever it was called, but for projects. I just rememberd because as part of testing this I ended up having to create a first project by turning on the null auth backend, then switching back to the keystone backend. That's not really a workable solution though.

Shouldn't be hard to just add another similar command, if folks think that's a good approach.

@henn
Copy link
Contributor

henn commented Aug 19, 2016

@zenhack I'm going to merge this now since the code is good and we want to prevent bitrotting. Two requests:

  1. If it's straightforward, could you make a PR that detects a keystone-related auth error and prints a helpful message?

  2. If a user comes in as an admin to a non-bootstrapped HIL (thus, having no projects), will that still allow them to do stuff as a HIL admin?

@henn
Copy link
Contributor

henn commented Aug 19, 2016

+1; merging

@henn henn merged commit 8ed547b into CCI-MOC:master Aug 19, 2016
@zenhack
Copy link
Contributor Author

zenhack commented Aug 19, 2016

Quoting Jason Hennessey (2016-08-18 23:32:46)

[1]@zenhack I'm going to merge this now since the code is good and we
want to prevent bitrotting. Two requests:

  1. If it's straightforward, could make a PR that detects a
    keystone-related auth error and prints a helpful message?

It's not immediately obvious to me how to differentiate different forms
of 401; it does at least print out the authentication required message.
The HIL server spits out the same message for basically any auth(Z)
related failure. It might be nice to at least see who yelled at us:
keystone or HIL, but the keystone client seems to throw the same
exception in both cases. I'd have to do some digging to figure out if
there's a good way to differentiate. Maybe another thing to think about
when designing client libraries?

  1. If a user comes in as an admin to a non-bootstrapped HIL (thus,
    having no projects), will that still allow them to do stuff as a HIL
    admin?

You mean as an Openstack project that has admin rights? Not unless that
project is already in the DB; HIL rejects any requests by projects it
doesn't know about. You'll get a thing in the logs to the effect that
authentication checked out, but the project wasn't in the DB.

@henn
Copy link
Contributor

henn commented Aug 19, 2016

You mean as an Openstack project that has admin rights? Not unless that
project is already in the DB; HIL rejects any requests by projects it
doesn't know about. You'll get a thing in the logs to the effect that
authentication checked out, but the project wasn't in the DB.

Hmmm... it sounds like we do have a problem then. What if we allowed an admin from any OpenStack project to be a HIL admin, regardless of whether the project was registered? In normal OpenStack, I don't believe you need to pre-register projects anyhow - we did it more for keeping our own internal tables straight and maybe in lieu of quotas.

@knikolla @gsilvis - appreciate your thoughts too.

@gsilvis
Copy link
Contributor

gsilvis commented Aug 19, 2016

Agree with @henn here: admins on projects not yet registered with HIL should still be able to perform any function (unless it's a function that is scoped to the user's project). The authorization layer shouldn't care if a project has been created. But, if the admin tries to do something like add a node to their project, then they should get the non-auth error "Project does not exist."

@zenhack
Copy link
Contributor Author

zenhack commented Aug 19, 2016 via email

@henn
Copy link
Contributor

henn commented Aug 19, 2016

Awesome - I think we have a plan here.
Also, once we have the ability to be admins, the bootstrapping problem should be taken care of.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants