New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add whoami command #535
add whoami command #535
Conversation
|
Design page: http://www.freeipa.org/page/V4/Who_Am_I_Command |
|
I believe that in CLI |
|
Uhm, no, I don't want that. It makes the command behaving differently depending on a context and that would be broken. For client-side plugin that would also be an abuse of interface, I'd say. |
|
Ok. It just doesn't seem right to have a command which shows something that's not immediately useful to the user. I am not sure whether we should have it enabled for CLI. |
|
We can disable it for CLI, that's not a problem. |
ipaserver/plugins/whoami.py
Outdated
| __doc__ = _(""" | ||
| Return a description of currently authenticated identity | ||
|
|
||
| Who am I command returns information on who to get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Major nitpick: I believe you meant "...returns information on how to get..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
ipaserver/plugins/whoami.py
Outdated
|
|
||
| output_params = ( | ||
| Str('object', label=_('Object class name')), | ||
| Str('details', label= _('Function to get details')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please call the param "command" instead of "details", it's much more descriptive. "details" does not mean anything.
ipaserver/plugins/whoami.py
Outdated
| object that handles the container where this DN belongs to. Then report | ||
| details about this object. | ||
| """ | ||
| exceptions = dict( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the future: dict() should generally be avoided for CPython and {} should be used instead to init dictionaries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
ipaserver/plugins/whoami.py
Outdated
| o_func = None | ||
| o_args = [] | ||
| o_opts = [] | ||
| for o in api.Object(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you don't need to init api.Object() here but that does not matter much so feel free to leave it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to init it because api is fully initialized already at the point when any plugin command is run. api.Object() returns an iterator, it is not a class constructor.
ipaserver/plugins/whoami.py
Outdated
| # We found exact container this DN belongs to | ||
| o_name = unicode(o.name) | ||
| o_args = [unicode(entry.single_value.get(o.primary_key.name))] | ||
| o_opts = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no reason to have options in the output since you never add anything there, please, remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On further thinking I removed it.
|
Please, disable the command for CLI since by itself it does not bring any valuable information to the user, in my opinion it can only confuse them. It'll be easier to turn it on if there's a demand for it rather than turning it off if it confuses some people. |
4a8a7f8
to
8813bd2
Compare
|
Updated. |
|
@abbra Thank you for the changes, the patch seems fine now. I tested the user/service/host scenarios and it worked fine. I couldn't test idviews since trusts are broken now but I assume it should work fine as well. |
Whoami command allows to query details about currently
authenticated identity. The command returns following information:
* object class name
* function to call to get actual details about the object
* arguments to pass to the function
There are five types of objects that could bind to IPA using their
credentials. `ipa whoami` call expects one of the following:
* users
* staged users
* hosts
* Kerberos services
* ID user override from the default trust view
The latter category of objects is automatically mapped by SASL GSSAPI
mapping rule in 389-ds for users from trusted Active Directory forests.
The command is expected to be used by Web UI to define proper view for
the authenticated identity. It is not visible in the command line
interface is `ipa` command.
Below is an example of how communication looks like for a host
principal:
# kinit -k
# ipa console
(Custom IPA interactive Python console)
>>> api.Command.whoami()
{u'command': u'host_show/1', u'object': u'host', u'arguments': (u'ipa.example.com',)}
>>>
Fixes https://pagure.io/freeipa/issue/6643
|
Done. I've also updated the design page to reflect the changes. |
|
Thank you, ACK. Please don't close the ticket, we still need tests. |
|
master:
|
ipa whoamicommand allows to query details about currentlyauthenticated identity. The command returns following information:
There are five types of objects that could bind to IPA using their
credentials.
ipa whoamicall expects one of the following:The latter category of objects is automatically mapped by SASL GSSAPI
mapping rule in 389-ds for users from trusted Active Directory forests.
The command is expected to be used by Web UI to define proper view for
the authenticated identity.
Below is an example of how communication looks like for an Active
Directory user which has ID override in 'Default Trust View'.
Fixes https://pagure.io/freeipa/issue/6643