Project

General

Profile

Actions

Bug #4510

closed

Can't create auth_source_ldap with v1 and v2 api

Added by Ronny M over 10 years ago. Updated over 10 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Foreman 1.4.1

Can't create auth_source_ldap with api

POSTING:

 
{
 "auth_source_ldap": {
   "type": "AuthSourceLdap",
   "name": "ldap1",
   "host": "ldap.example.com",
 }
}

With the following url's

foreman.localdomain/api/auth_source_ldaps
foreman.localdomain/api/v1/auth_source_ldaps
foreman.localdomain/api/v2/auth_source_ldaps

Alway's results in the following error: (doesn't matter how many parameters I specify)

{
    "auth_source_ldap": {
        "id": null,
        "errors": {
            "name": [
                "can't be blank" 
            ],
            "host": [
                "can't be blank" 
            ]
        },
        "full_messages": [
            "Name can't be blank",
            "Server can't be blank" 
        ]
    }
}

In production.log only the following error is shown.

Started POST "/api/auth_source_ldaps" for 192.168.88.1 at 2014-03-01 01:12:46 -0800
Processing by Api::V1::AuthSourceLdapsController#create as JSON
  Parameters: {"apiv"=>"v1"}
  User Load (0.8ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 1]]
Setting current user thread-local variable to admin
   (0.3ms)  BEGIN
  AuthSource Exists (0.5ms)  SELECT 1 AS one FROM "auth_sources" WHERE "auth_sources"."name" = '' LIMIT 1
   (0.1ms)  ROLLBACK
Unprocessable entity AuthSourceLdap (id: new):
  Name can't be blank
  Server can't be blank

  Rendered api/v1/errors/unprocessable_entity.json.rabl (1.5ms)
Body: {"auth_source_ldap":{"id":null,"errors":{"name":["can't be blank"],"host":["can't be blank"]},"full_messages":["Name can't be blank","Server can't be blank"]}}
Completed 422 Unprocessable Entity in 303ms (Views: 2.6ms | ActiveRecord: 1.8ms)

Also updating an auth_source_ldap doesn't work, no error occurs but changing port from 389 to 3890 resuls in the following loggin and no change.

Started GET "/api/v1/auth_source_ldaps/4" for 192.168.88.1 at 2014-03-01 02:06:06 -0800
Processing by Api::V1::AuthSourceLdapsController#show as JSON
  Parameters: {"apiv"=>"v1", "id"=>"4"}
  ^[[1m^[[35mUser Load (0.5ms)^[[0m  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 1]]
Setting current user thread-local variable to admin
  ^[[1m^[[36mAuthSourceLdap Load (0.5ms)^[[0m  ^[[1mSELECT "auth_sources".* FROM "auth_sources" WHERE "auth_sources"."type" IN ('AuthSourceLdap') AND "auth_sources"."id" = 4 LIMIT 1^[[0m
  Rendered api/v1/auth_source_ldaps/show.json.rabl (90.0ms)
Body: {"auth_source_ldap":{"id":4,"type":"AuthSourceLdap","name":"ldap","host":"ldap.example.com","port":389,"account":"","base_dn":"","ldap_filter":"","attr_login":"","attr_firstname":"","attr_lastname":"","attr_mail":"","onthefly_register":false,"tls":false,"created_at":"2014-03-01T09:31:06Z","updated_at":"2014-03-01T09:31:06Z"}}
Completed 200 OK in 95ms (Views: 90.8ms | ActiveRecord: 1.0ms)

Started PUT "/api/v1/auth_source_ldaps/4" for 192.168.88.1 at 2014-03-01 02:06:20 -0800
Processing by Api::V1::AuthSourceLdapsController#update as JSON
  Parameters: {"apiv"=>"v1", "id"=>"4"}
  ^[[1m^[[35mUser Load (0.5ms)^[[0m  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 1]]
Setting current user thread-local variable to admin
  ^[[1m^[[36mAuthSourceLdap Load (0.7ms)^[[0m  ^[[1mSELECT "auth_sources".* FROM "auth_sources" WHERE "auth_sources"."type" IN ('AuthSourceLdap') AND "auth_sources"."id" = 4 LIMIT 1^[[0m
  ^[[1m^[[35m (0.3ms)^[[0m  BEGIN
  ^[[1m^[[36mAuthSource Exists (0.5ms)^[[0m  ^[[1mSELECT 1 AS one FROM "auth_sources" WHERE ("auth_sources"."name" = 'ldap' AND "auth_sources"."id" != 4) LIMIT 1^[[0m
  ^[[1m^[[35m (0.3ms)^[[0m  COMMIT
Body: {"auth_source_ldap":{"account":"","account_password":"","attr_firstname":"","attr_lastname":"","attr_login":"","attr_mail":"","base_dn":"","created_at":"2014-03-01T09:31:06Z","host":"ldap.example.com","id":4,"ldap_filter":"","name":"ldap","onthefly_register":false,"port":389,"tls":false,"updated_at":"2014-03-01T09:31:06Z"}}
Completed 200 OK in 12ms (Views: 0.8ms | ActiveRecord: 0.0ms)

Files

Screenshot from 2014-03-03 10_26_36.png View Screenshot from 2014-03-03 10_26_36.png 163 KB postman setup Dominic Cleal, 03/03/2014 10:27 AM
Actions

Also available in: Atom PDF