Import puppetclass permissions no longer work

Problem:
Hello, after we upgrade to 3.2 our Foreman it seems that the script we were previously using to import automatically all puppetclasses via POST API request is not working with the previous permissions from Foreman 2.5

I know that Puppet was extracted from core and there were some changes but looking into the permissions the user might require it seems that my user is having the appropiate rights.

Expected outcome:
Successfull import

Foreman and Proxy versions:
3.2
Foreman and Proxy plugin versions:

Distribution and version:
CentOS 7
Other relevant data:
API request response

{
  "error": {"message":"Access denied","details":"Missing one of the required permissions: ","missing_permissions":[ ]}
}

My permissions defined:

If I give Administrator role the script runs successfully but this is not the right way, any idea on what extra permissions user might require since the response does not specify any

Can you please post the exact command you sent via API?

API request comes from a ruby functions:

def import_classes()
    uri = URI("https://"+SERVER_NAME+"/api/smart_proxies/"+get_smart_proxy()+"/import_puppetclasses")
    req = Net::HTTP::Post.new(uri)
    req.basic_auth USER, PASSWORD
    req['Content-Type'] = "application/json"

    response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|
        http.request(req)
    end
    response.body

end

I call POST on https://Foreman_FQDN/api/smart_proxies/:id/import_puppetclasses as in API v2 docs

This probably got lost during the transfer to the plugin.

If you want to try to fix it, you could try and patch the plugin by adding this line after line 147 in the above file:
'api/v2/smart_proxies' => [:import_puppetclasses],

3 Likes

@asolomon If you try it, let me know if it works :slight_smile:

Trying now, it seems to work at first, but let me double check and I’ll be back with an answer shortly.
LE. Worked, thank you @nadjaheitmann

2 Likes