Welcome to World of IPTV

With

+23k members
+11k threads
+106k posts

we are the most popular IPTV community on the web. 

IMPORTANT NOTE:
WE HAVE RECENTLY NOTICED THAT TOO MANY DOUBLE FAKE ACCOUNTS ARE CREATED IN THE PAST.
TO PREVENT THIS ISSUE THE DECISION WAS MADE THAT IN THE FUTURE A ANNUALLY FEE 20 EURO WILL BE RAISED FOR NEW MEMBERSHIPS.

Join now to the World of IPTV

Forum Rules

Before you start, check out the forum rules first

Account upgrade

Upgrade your account to get access to full features

Advertising

Would you like to place your advertisement with us ?

Resources Manager

Hundreds of IPTV scripts and apps are available for download

Tutorial What are HMAC Keys in XUI.ONE ?

redhat

Administrator
Staff member
Administrator
Chief Moderator
Moderator
Joined
Jun 19, 2019
Messages
3,074
Reaction score
14,825
Points
134
Location
root[@]woi
What are HMAC Keys in XUI.ONE ?

HMAC keys were integrated into XUI a while ago, but without an explanation as to how it works and what it is for, not many people would be able to successfully implement it.

The idea behind using HMAC is to be able to use your own form of authentication on your website, yet stream from XUI and be able to manage connections accordingly. Instead of using a XUI username and password to authenticate a stream, you can generate a HMAC key with a unique identifier and restrictions that XUI will be able to verify and log.

Firstly, you need to access the XUI Admin panel and generate a HMAC Key.

1655245930135.png


Done! You now have your HMAC Key: 007B50D51E14F409104FCACB48849B2C
You would then need to keep it safe somewhere as you won't be able to see it again, it's encrypted in the database.

Token Parameters:

  • Stream ID
  • Extension
  • Max Connections
  • Identifier
  • Expiration - optional
  • User IP - optional

From the above you can build a token as follows:
{StreamID}##{Extension}##{Expiry}##{IP}##{Identifier}##{MaxConnections}


An example being a user you have authenticated on your own system would like to view stream 44, you want restrict them to their IP address and only allow them to view the stream using this URL for 24 hours, with 1 max connection:
44##m3u8##1613771149##192.168.0.1##USER_JOHN_DOE##1


You can then generate a HMAC token using the above string, and the HMAC key you generated earlier. An example in PHP would be:
$rResult = hash_hmac("sha256", "44##m3u8##1613771149##192.168.0.1##USER_JOHN_DOE##1", "007B50D51E14F409104FCACB48849B2C");


Your HMAC token in this example would be:
ed8d97309bd6cd1add1ef427e0f5cc861204154a4ccf8ddcb119e3441199842a


Finally, build your URL to the stream using your HMAC token and token parameters as follows:
http://yourwebsite.com:8080/stream/auth?stream=44&expiry=1613771149&extension=m3u8&identifier=USER_JOHN_DOE&max=1&ip=192.168.0.1&hmac=ed8d97309bd6cd1add1ef427e0f5cc861204154a4ccf8ddcb119e3441199842a


That's it! You have a working URL that will expire in 24 hours and be restricted to IP 192.168.0.1, allowing only 1 connection at a time to stream 44 and generating a HLS m3u8 playlist.


Understandably this may seem foreign to a lot of you, however if you're a developer, this is a secure and easy method to allow external access to your streaming platform without having to set up a new XUI line for each of your external users.
 
Last edited:

GotSugar

Extended Member
Ext. Member
Joined
Sep 30, 2019
Messages
1
Reaction score
1
Points
11
Location
Rep Dom
What are HMAC Keys in XUI.ONE ?

HMAC keys were integrated into XUI a while ago, but without an explanation as to how it works and what it is for, not many people would be able to successfully implement it.

The idea behind using HMAC is to be able to use your own form of authentication on your website, yet stream from XUI and be able to manage connections accordingly. Instead of using a XUI username and password to authenticate a stream, you can generate a HMAC key with a unique identifier and restrictions that XUI will be able to verify and log.

Firstly, you need to access the XUI Admin panel and generate a HMAC Key.

View attachment 3147


Done! You now have your HMAC Key: 007B50D51E14F409104FCACB48849B2C
You would then need to keep it safe somewhere as you won't be able to see it again, it's encrypted in the database.

Token Parameters:

  • Stream ID
  • Extension
  • Max Connections
  • Identifier
  • Expiration - optional
  • User IP - optional

From the above you can build a token as follows:
{StreamID}##{Extension}##{Expiry}##{IP}##{Identifier}##{MaxConnections}


An example being a user you have authenticated on your own system would like to view stream 44, you want restrict them to their IP address and only allow them to view the stream using this URL for 24 hours, with 1 max connection:
44##m3u8##1613771149##192.168.0.1##USER_JOHN_DOE##1


You can then generate a HMAC token using the above string, and the HMAC key you generated earlier. An example in PHP would be:
$rResult = hash_hmac("sha256", "44##m3u8##1613771149##192.168.0.1##USER_JOHN_DOE##1", "007B50D51E14F409104FCACB48849B2C");


Your HMAC token in this example would be:
ed8d97309bd6cd1add1ef427e0f5cc861204154a4ccf8ddcb119e3441199842a


Finally, build your URL to the stream using your HMAC token and token parameters as follows:
http://yourwebsite.com:8080/stream/auth?stream=44&expiry=1613771149&extension=m3u8&identifier=USER_JOHN_DOE&max=1&ip=192.168.0.1&hmac=ed8d97309bd6cd1add1ef427e0f5cc861204154a4ccf8ddcb119e3441199842a


That's it! You have a working URL that will expire in 24 hours and be restricted to IP 192.168.0.1, allowing only 1 connection at a time to stream 44 and generating a HLS m3u8 playlist.


Understandably this may seem foreign to a lot of you, however if you're a developer, this is a secure and easy method to allow external access to your streaming platform without having to set up a new XUI line for each of your external users.
Hi, I tried this but unfortunately always return 404 Not Found. All parameter, hmac token and everything else are correct but seems something is missing. Did anyone figure it out? Thx
 

Dazzler1985

Extended Member
Ext. Member
Joined
Aug 19, 2019
Messages
8
Reaction score
183
Points
39
Location
NL
I tried this as well but it seems in 1.5.5 there is no /stream/auth? or auth.php file reachable if you look in the config of nginx as well this is not the correct endpoint of it so the instructions wont work and i cant seem to find if hmac is even in working condition in 1.5.5 . If so please would you be so kind to give a working example ?
 
Channels MatchTime Unblock CDN Offshore Server Contact
100 cnx / 90€ 5Gbps / 180€ 48CPU-256GRAM 10Gbps 569€ Skype live:giefsl
500 cnx / 350€ 10Gbps / 350€ 48CPU-128GRAM 5Gbps / 349€ TG @changglobize
1000 cnx / 500€ 20Gbps / 700€ 40CPU-128GRAM 20Gbps / €980 http://coronaserver.com
shape1
shape2
shape3
shape4
shape5
shape6
Top
AdBlock Detected

We know, ad-blocking software do a great job at blocking ads. But our site is sponsored by advertising. 

For the best possible site experience please take a moment to disable your AdBlocker.
You can create a Account with us or if you already have account, you can prefer an Account Upgrade.

I've Disabled AdBlock