Due to the characteristics of global coverage, on-demand access, and large capacity, the low earth orbit (LEO) satellite communication (SatCom) has become one promising technology to support the Internet-of-Things (IoT). However, due to the scarcity of satellite spectrum and the high cost of designing satellites, it is difficult to launch a dedicated satellite for IoT communications. To facilitate IoT communications over LEO SatCom, in this paper, we propose the cognitive LEO satellite system, where the IoT users act as the secondary user to access the legacy LEO satellites and cognitively use the spectrum of the legacy LEO users. Due to the flexibility of code division multiple access (CDMA) in multiple access and the wide use of CDMA in LEO SatCom, we apply CDMA to support cognitive satellite IoT communications. For the cognitive LEO satellite system, we are interested in the achievable rate analysis and resource allocation. Specifically, considering the randomness of spreading codes, we use the random matrix theory to analyze the asymptotic signal-to-interference-plus-noise ratios (SINRs) and accordingly obtain the achievable rates for both legacy and IoT systems. The power of the legacy and IoT transmissions at the receiver are jointly allocated to maximize the sum rate of the IoT transmission subject to the legacy satellite system performance requirement and the maximum received power constraints. We prove that the sum rate of the IoT users is quasi-concave over the satellite terminal receive power, based on which the optimal receive powers for these two systems are derived. Finally, the resource allocation scheme proposed in this paper has been verified by extensive simulations.