| View previous topic :: View next topic |
| Author |
Message |
Anonymous Guest
|
Posted: Wed Feb 07, 2007 9:47 pm Post subject: More on URL authentication please. |
|
|
| I've been trying to get URL authentication to work using the example scripts provided with the Icecast download. The database part of the scripts work fine. I can add and delete users and passwords etc. However, after running the auth script and entering a correct username and password and mountpoint info etc nothing happens. I see the browser has called up the action script and that's it. Nothing else. I saw in another post the option names have been changed? Maybe that's part of the problem? I would appreciate any pointers on getting URL authentication to work as expected. Thanks! |
|
| Back to top |
|
 |
karlH Code Warrior

Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Wed Feb 07, 2007 10:40 pm Post subject: |
|
|
You need to check the icecast and web server logs, but your browser is not responsible for calling the scripts. The actions are taken by icecast when certain events happen. You may have the wrong event names and if you do then nothing will be listed in the web server logs.
karl. |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Thu Feb 08, 2007 4:32 pm Post subject: |
|
|
I see nothing in the logs pertaining to authorization.
Here's the relevant part of my config file ("mywebsite" would be a valid url):
| Code: |
<authentication type="url">
<option name="mount_add" value="http://mywebsite/action.php"/>
<option name="mount_remove" value="http://mywebsite/action.php"/>
<option name="listener_add" value="http://mywebsite/action.php"/>
<option name="listener_remove" value="http://mywebsite/action.php"/>
<option name="auth_header" value="icecast-auth-user: 1"/>
<option name="timelimit_header" value="icecast-auth-timelimit:"/>
</authentication> |
If the demo script is working properly is it supposed to start the player if the username and password is correct? Does "action.php" need to reside on the same computer as the Icecast server? |
|
| Back to top |
|
 |
karlH Code Warrior

Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Thu Feb 08, 2007 6:30 pm Post subject: |
|
|
That snippet looks ok, but it's hard to say which part is failing from just that. Could be misnamed mountpoint, commented out xml, libcurl not linked in, or even name resolution failing. Check your logs for failure messages, check if icecast is really issuing the requests of your web server.
To answer your last part, no, authorization is requested by icecast from some other server which may be local but is not required to be.
karl. |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Fri Feb 09, 2007 12:16 am Post subject: |
|
|
I wonder if this test script (testauth.php) is leading me in the wrong direction. As you can see the form action calls up the action script. This doesn't seem right as that handles events from the Icecast server. So assuming I have URL authentication enabled, what is the URL I should point to for listening to the stream and what should happen? Just the usual http://localhost:8000/mymountpoint format?
| Code: |
<form method=POST action="action.php">
<table border=0>
<tr><td>Username</td><td><input type=text name="user" size=30></td></tr>
<tr><td>Password</td><td><input type=text name="pass" value="monkey" size=30></td></tr>
<tr><td>Mountpoint</td><td><input type=text name="mount" value="/mystream.ogg" size=30></td></tr>
<tr><td>Server</td><td><input type=text name="server" value="localhost" size=30></td></tr>
<tr><td>Port</td><td><input type=text name="port" value="8000" size=30></td></tr>
<tr><td>Action</td><td><input type=text name="action" value="auth" size=30></td></tr>
</table>
<input type="Submit">
</form> |
|
|
| Back to top |
|
 |
karlH Code Warrior

Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Fri Feb 09, 2007 2:35 am Post subject: |
|
|
yes, although you may specifiy a username/password in the url as well.
karl. |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Fri Feb 09, 2007 6:05 am Post subject: |
|
|
| karlH wrote: |
yes, although you may specifiy a username/password in the url as well.
karl. |
Such as http://username:password@local:8000/mymount ?
I checked the logs. I see
| Code: |
[2007-02-09 00:53:55] INFO auth/auth.c adding client for authentication
[2007-02-09 00:53:55] INFO auth_url/auth_url.c client auth (http://mywebsite.com/action.php) failed with "" |
When invoking the player with http://localhost:8000/mymount and Winamp as the default player, Winamp will display its own login dialog and not play the stream. I was under the impression URL authentication would allow our own methods of doing all the checking and then start the stream if all was well. Is the example not working correctly or am I just not understanding what's happening here? |
|
| Back to top |
|
 |
karlH Code Warrior

Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Fri Feb 09, 2007 1:23 pm Post subject: |
|
|
Based on the log snippet, it looks like your php failed the request, so no auth_header set and no description of the failure (""). I don't know what your action.php does but obviously it failed the listener in this case.
karl. |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Fri Feb 09, 2007 7:12 pm Post subject: |
|
|
OK, I have most of this sorted out now. I was pointing to the wrong directory so of course the script was not run.
If using a URL such as http://user:pass@local:8000/mymount it will run the script and behave as expected. My problem with this is that you can see the password if checking the URL in the player. And also WIndows MEdia PLayer does not like URL's in that form. Is there any way to use authentication without embedding the user name and password in the URL? I'd like the script to get the info from a form and then validate the info. If it's OK then I'd like the script to allow or disallow the stream to play. I thought I could control that by using the lines
header('icecast-auth-user: 1') or header('icecast-auth-user: 0') in conjunction with a "plain" URL but apparent not. Am I barking up the wrong tree? |
|
| Back to top |
|
 |
karlH Code Warrior

Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Fri Feb 09, 2007 8:56 pm Post subject: |
|
|
We are unable to fix windows media player, you have to ask microsoft for that (they may prefer asx instead of m3u). If you issue a url without the user/pw embedded then the player should get a response that usually triggers a popup box. The process you have for enabling the listener is correct but the details are passed from icecast via POST, other ways tend to have security issues.
karl. |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Fri Feb 09, 2007 10:56 pm Post subject: |
|
|
| karlH wrote: |
| We are unable to fix windows media player, you have to ask microsoft for that (they may prefer asx instead of m3u). |
I understand that. I was just mentioning it.
I've been tinkering with code similar to the pseudo code below. Is this an acceptable method of authentication based on data from a form?
| Code: |
//username and password from form and launch default m3u player
if ($action == 'auth') {
header('Content-type: audio/x-mpegurl');
echo 'http://' . $username . ':' . $password . '@localhost:8000/mymount';
exit;
}
//Code runs when Icecast sends listener_add event
if ($action == $listener_add) {
//code to check username and password would go here
if (UserAndPassValid){
header('icecast-auth-user: 1');
header('icecast-auth-message: OK');
}else{
header('icecast-auth-user: 0');
header('icecast-auth-message: Authentication failed');
} |
|
|
| Back to top |
|
 |
karlH Code Warrior

Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Fri Feb 09, 2007 11:48 pm Post subject: |
|
|
The php is not required to send any content back to the icecast, only the headers for icecast to check for. It's also fairly pointless to put authentication on a playlist but not on a stream.
karl. |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Sat Feb 10, 2007 12:17 am Post subject: |
|
|
Does the stream have to be launched first before any authentication can take place? Is it possible to have the user fill out a form first and then call a script that checks username and password (and maybe more items) and then launch the stream? I suppose I'm just not understanding how URL authentication works.
We've established that my mountpoint is set up properly for URL authentication. Would you be so kind as to elaborate on the basics of what needs to be done with URL authentication? In my case I want:
1) User fills out form.
2) Script checks for valid data.
3) If data is OK launch stream
Items 1and 2 are no problem...I've gotten that far. I'm just having a real hard time with item 3.
I'm just about to give up and use plain ol' basic htpasswd authentication which works "out of the box". I appreciate your help and patience so far. |
|
| Back to top |
|
 |
karlH Code Warrior

Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Sat Feb 10, 2007 2:55 am Post subject: |
|
|
From your description above, you sound like you are just checking the contents from a web form, which is different from validating a listener connecting with a player. The best a web form can do is produce the playlist which will start the player, but that is no good unless you authenticate the actual stream being played.
The player (eg winamp/xmms) opens a connection to icecast and supplies the details (user/pass/mountpoint etc), icecast then checks those details and either accepts or drops the connection based on the php result. Whether you check for authentication when requesting the playlist is independent from the stream authentication.
karl. |
|
| Back to top |
|
 |
Anonymous Guest
|
Posted: Sat Feb 10, 2007 4:05 am Post subject: |
|
|
I see. So it appears to be very similar to htpasswd authentication. Then my solution will be to use htpasswd authentication, have the user fill out a form, I'll check the various credentials in addition to the user name and password and then I'll build the m3u dynamically with PHP like below to launch the default m3u player.
| Code: |
header('Content-type: audio/x-mpegurl');
echo 'http://' . $username . ':' . $password . '@localhost:8000/mymount'; |
Thanks for all your help. |
|
| Back to top |
|
 |
|