Skip to content
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

st2 apikey create -k fails when authentication disabled #3578

Closed
LindsayHill opened this issue Jul 18, 2017 · 0 comments
Closed

st2 apikey create -k fails when authentication disabled #3578

LindsayHill opened this issue Jul 18, 2017 · 0 comments
Assignees
Labels
Milestone

Comments

@LindsayHill
Copy link
Contributor

If authentication is disabled, st2 apikey create -k fails with this error:

vagrant@bwcvagrant:~$ st2 apikey create -k
ERROR: 500 Server Error: Internal Server Error
MESSAGE: Internal Server Error for url: http://127.0.0.1:9101/v1/apikeys

st2api.log contains this:

2017-07-18 05:36:03,099 140399285519696 ERROR router [-] Failed to call controller function "post" for operation "st2api.controllers.v1.auth:api_key_controller.post": 'NoneType' object has no attribute 'name'
Traceback (most recent call last):
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/router.py", line 414, in __call__
    resp = func(**kw)
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2api/controllers/v1/auth.py", line 140, in post
    api_key_api.user = requester_user.name or cfg.CONF.system_user.user
AttributeError: 'NoneType' object has no attribute 'name'
2017-07-18 05:36:03,103 140399285519696 ERROR error_handling [-] API call failed: 'NoneType' object has no attribute 'name'
Traceback (most recent call last):
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/middleware/error_handling.py", line 46, in __call__
    return self.app(environ, start_response)
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/router.py", line 445, in as_wsgi
    resp = self(req)
  File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/router.py", line 418, in __call__
    raise e
AttributeError: 'NoneType' object has no attribute 'name' (_exception_data={},_exception_class='AttributeError',_exception_message="'NoneType' object has no attribute 'name'")
2017-07-18 05:36:03,105 140399285519696 INFO logging [-] 07293032-81fe-41ea-8d4d-cdd4e0e222c6 - 500 46 7.573ms (content_length=46,request_id='07293032-81fe-41ea-8d4d-cdd4e0e222c6',runtime=7.573,remote_addr='127.0.0.1',status=500,method='POST',path='/v1/apikeys')

Calling st2 apikey create -k -u st2admin works.

Looking at the code, this is the problem: https://github.com/StackStorm/st2/blob/master/st2api/st2api/controllers/v1/auth.py#L140

            if not getattr(api_key_api, 'user', None):
                api_key_api.user = requester_user.name or cfg.CONF.system_user.user

I think that code should be checking to see if requester_user.name exists, not just checking to see if it is None.

Expected behavior: If authentication is disabled, and the user has not specified a username for the API key, it should default to using the system_user (by default stanley).

Environment:

  • Ubuntu 14.04
  • ST2 2.3.1

System installed from Vagrant/one-line install. Change made to /etc/st2/st2.conf to set enable = False in [auth] section.

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

No branches or pull requests

3 participants