Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(liveman): add admin auth #215

Merged
merged 9 commits into from
Sep 6, 2024
Merged

feat(liveman): add admin auth #215

merged 9 commits into from
Sep 6, 2024

Conversation

a-wing
Copy link
Member

@a-wing a-wing commented Aug 31, 2024

No description provided.

@a-wing a-wing added the mod::liveman Cloud Manager label Aug 31, 2024
@a-wing a-wing added this to the 0.6.0 milestone Aug 31, 2024
@a-wing
Copy link
Member Author

a-wing commented Sep 4, 2024

How to enabled auth: at conf liveman.toml

[auth]
# JSON WEB TOKEN secret
secret = "<jwt_secret>"
# static JWT token, superadmin, debuggger can use this token
tokens = ["live777"]

# Admin Dashboard Accounts
[[auth.accounts]]
username = "live777"
password = "live777"

Use conf start

cargo run --package=liveman --features=liveion -- -c conf/liveman.toml

Get Json Web Token

curl -X POST -H 'Content-Type: application/json' \
http://localhost:8888/login \
-d '{"username": "live777", "password": "live777"}'
# {"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IioiLCJleHAiOjE3MjU1NDk4MzMsIm1vZGUiOjd9.LmEIyTpnn3nhIAOJ4BwZo9OndR9kq7j3Bs-hC4xQWpY","token_type":"Bearer"}

Use Json Web Token:

curl -H 'Content-Type: application/json' \
-H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IioiLCJleHAiOjE3MjU1NDk4MzMsIm1vZGUiOjd9.LmEIyTpnn3nhIAOJ4BwZo9OndR9kq7j3Bs-hC4xQWpY' \
http://localhost:8888/api/streams/

@a-wing
Copy link
Member Author

a-wing commented Sep 4, 2024

We need a login page in liveman webui @rocka

@a-wing
Copy link
Member Author

a-wing commented Sep 6, 2024

When you login, you can create a token for single stream.

About create a token:

id: stream id, use * match any stream id
duration: Validity duration (second)

Permission:

  • subscribe, you can use whep
  • publish, you can use whip
  • admin, you can use delete and cascade...
curl -X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IioiLCJleHAiOjE3MjU2OTg0MjYsIm1vZGUiOjd9.sKmH2AbLCER46eDwJm9MFLPoqavvXAzcNkCcXA1qTXs' \
http://localhost:8888/token \
-d '{"id":"233","duration":3600,"subscribe":true,"publish":true,"admin":true}'

@a-wing a-wing marked this pull request as ready for review September 6, 2024 11:45
@a-wing a-wing merged commit 33a1627 into main Sep 6, 2024
6 checks passed
@a-wing a-wing deleted the feat/auth-admin branch September 6, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mod::liveman Cloud Manager
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant