Since both x + 1 and x - 1 are factors of f(x), we have the factorization
x³ + 2ax + b = (x + 1) (x - 1) (x - b)
where the last root must be x = b in order that b is the constant term in the cubic.
Expanding the right side and equating coefficients gives
x³ + 2ax + b = x³ - bx² - x + b
which tells us
-b = 0 ⇒ b = 0
2a = -1 ⇒ a = -1/2
Then we have
f(x) = x³ + 2 (-1/2) x + b = x³ - x
or
f(x) = x (x + 1) (x - 1)