Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

url autentification

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server
View previous topic :: View next topic  
Author Message
nesale



Joined: 17 Apr 2014
Posts: 19

PostPosted: Tue Oct 14, 2014 10:23 am    Post subject: url autentification Reply with quote

Hi

I want to do to the listener could listen to the radio only my website.

In my icecast add (Icecast 2.3.3-kh10)

Code:

<mount>
        <mount-name>/name.mp3</mount-name>
        <authentication type="url">
        <option name="listener_add" value='http://example.com/auth/listener_add.php'/>
        <option name="auth_header" value="icecast-auth-user: 1"/>
        <option name="presume_innocent" value="yes"/>
        <option name="handlers" value="50"/>
        </authentication>
</mount>


php script
Code:

<?php
$ag = urldecode($_SERVER['HTTP_HOST']);
$hostname = "example.com";
$pos = strpos($ag, $hostname);
if ($pos === false) {
header("icecast-auth-user: 0");
}
else {
header("icecast-auth-user: 1");
}
?>


What am i doing wrong? How do I know where not working?
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Tue Oct 14, 2014 12:22 pm    Post subject: Reply with quote

There's a couple of factors that need to be determined first.

1. does you icecast build have libcurl support? (ldd /path/to/icecast should be enough to check for most people, but there is a log entry if it's disabled).

2. xml part looks ok, not sure if you really want presume innocent or handlers for your situation.

3. you don't need icecast-auth-user: 0, just don't return the header.

4. you can always use curl to send a request manually to verify the header based on the conditions you are checking for (HTTP_HOST in this case)

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nesale



Joined: 17 Apr 2014
Posts: 19

PostPosted: Wed Oct 15, 2014 10:23 am    Post subject: Reply with quote

Hello, Karl!

Thanks for you fast answer

karlH wrote:


1. does you icecast build have libcurl support? (ldd /path/to/icecast should be enough to check for most people, but there is a log entry if it's disabled).


In access.log and error.log information no.
How check what icecast build in support curl? Maybe rebuild icecast?

karlH wrote:

2. xml part looks ok, not sure if you really want presume innocent or handlers for your situation.

Remove directive
Code:

<option name="presume_innocent" value="yes"/>


karlH wrote:

3. you don't need icecast-auth-user: 0, just don't return the header.

change php script
Code:

<?php
$ag = urldecode($_SERVER['HTTP_HOST']);
$hostname = "example.com";
$pos = strpos($ag, $hostname);
if ($pos !=== false) {
header("icecast-auth-user: 1");
}
?>


True?

karlH wrote:

4. you can always use curl to send a request manually to verify the header based on the conditions you are checking for (HTTP_HOST in this case)

Please tell me example code
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Wed Oct 15, 2014 11:59 am    Post subject: Reply with quote

Like I said, the 'ldd ....' will be enough for most people as that will show you the sharedl libraries used and libcurl will be among them if it was enabled. The error log message if it was not enabled shows as

"Auth URL disabled, no libcurl support"

at level 3 and above you will see other auth_url lines when in use.

As for your php script, you have to decide on what the conditions are, the simplest case is

<?php
header("icecast-auth-user: 1");
?>

normally the php will test the _REQUEST array for settings not the _SERVER but that is completely up to you. As long as you return the icecast-auth-user header to accept the listener.

The test with curl use something like

curl --data-urlencode 'action=listener_add&mount=/&ip=127.0.0.1' http://example.com/auth.php


karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nesale



Joined: 17 Apr 2014
Posts: 19

PostPosted: Mon Oct 20, 2014 3:44 pm    Post subject: Reply with quote

karlH wrote:
Like I said, the 'ldd ....' will be enough for most people as that will show you the sharedl libraries used and libcurl will be among them if it was enabled. The error log message if it was not enabled shows as

"Auth URL disabled, no libcurl support"

at level 3 and above you will see other auth_url lines when in use.


In log it's ok

karlH wrote:

As for your php script, you have to decide on what the conditions are, the simplest case is

<?php
header("icecast-auth-user: 1");
?>

normally the php will test the _REQUEST array for settings not the _SERVER but that is completely up to you. As long as you return the icecast-auth-user header to accept the listener.

The test with curl use something like

curl --data-urlencode 'action=listener_add&mount=/&ip=127.0.0.1' http://example.com/auth.php


karl.


I run action=listener_add&port=8070&client=1&mount=/name.mp3&user=&pass=&ip=127.0.0.1

answer

Code:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://example.com/auth.php">here</a>.</p>
<hr>
<address>Apache/2.2.22 (Debian) Server at example.com Port 80</address>
</body></html>



in this case php script has this code

Code:

<?php
header("icecast-auth-user: 1");
?>



But still not working.
Please, what to do next?
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Tue Oct 21, 2014 2:26 am    Post subject: Reply with quote

are you sure you are querying your own web server with that? If your web server is not able to run your php files that url auth is not going to work.


karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber