CMK version: 2.1.0p8.cee and 2.1.0p9.cee
OS version: Ubuntu 20.04
I’m currently checking out the REST API and wanted to create a user programmatically. I used to do it with the Web-API and that works as expected. Now, with the REST-API I can create a user (and even log in as that user) but in the overview the user cannot be edited. Also, the authentication method seems broken:
I created this user with the very example from the REST API docs, i.e. with this code:
Create user script
#!/usr/bin/env python3
import pprint
import requests
HOST_NAME = "localhost"
SITE_NAME = "testsite"
API_URL = f"http://{HOST_NAME}/{SITE_NAME}/check_mk/api/1.0"
USERNAME = "automation"
PASSWORD = "***"
session = requests.session()
session.headers['Authorization'] = f"Bearer {USERNAME} {PASSWORD}"
session.headers['Accept'] = 'application/json'
resp = session.post(
f"{API_URL}/domain-types/user_config/collections/all",
headers={
"Content-Type": 'application/json',
},
json={
'username': 'cmkuser',
'fullname': 'Mathias Kettner',
'auth_option': {
'auth_type': 'password',
'password': 'password',
},
'contact_options': {
'email': 'user@example.com'
},
'roles': ['user'],
'contactgroups': ['all'],
},
)
if resp.status_code == 200:
pprint.pprint(resp.json())
elif resp.status_code == 204:
print("Done")
else:
raise RuntimeError(pprint.pformat(resp.json()))
I can fake the URL to edit that user in the GUI and that works. Also, it is possible to log in as that user. Neither omd restart nor cmk -O do help.
If I login as that user, the last seen timestamp is updated and the bullet gets green
but when I logout again it chenges back to Never logged in.
Is this a known problem?
