mirror of https://github.com/pikvm/pikvm.git
using 2fa with api
This commit is contained in:
parent
59c5aa6a58
commit
361c5a3dd8
24
docs/api.md
24
docs/api.md
|
|
@ -9,8 +9,28 @@ This document describes the PiKVM API. Since the system consists of microservice
|
||||||
All APIs are restricted to authentication. To make requests, you either need to auth each request individually,
|
All APIs are restricted to authentication. To make requests, you either need to auth each request individually,
|
||||||
or get a token and pass it as a cookie with each request.
|
or get a token and pass it as a cookie with each request.
|
||||||
|
|
||||||
!!! note
|
With enabled [2FA](auth.md#two-factor-authentication), you will need to add the one-time code to the password without spaces.
|
||||||
With enabled [2FA](auth.md#two-factor-authentication), you will need to add the one-time code to the password without spaces. That is, if the password is `foobar` and the code is `123456`, then you need to use `foobar123456` as the password.
|
That is, if the password is `foobar` and the code is `123456`, then you need to use `foobar123456` as the password.
|
||||||
|
|
||||||
|
The code can be generated using any TOTP library, for example in Python:
|
||||||
|
|
||||||
|
```python
|
||||||
|
import requests
|
||||||
|
import pyotp
|
||||||
|
|
||||||
|
user = "admin"
|
||||||
|
passwd = "admin"
|
||||||
|
secret = "3OBBOGSJRYRBZH35PGXURM4CMWTH3WSU" # Can be found in /etc/kvmd/totp.secret
|
||||||
|
|
||||||
|
print(requests.get(
|
||||||
|
url="https://pikvm/api/info",
|
||||||
|
verify=False, # For self-signed SSL certificate
|
||||||
|
headers={
|
||||||
|
"X-KVMD-User": user,
|
||||||
|
"X-KVMD-Passwd": passwd + pyotp.TOTP(secret).now(),
|
||||||
|
},
|
||||||
|
).text)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Single request auth
|
### Single request auth
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue