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 

Yet another URL auth Question

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



Joined: 29 Jan 2010
Posts: 4

PostPosted: Fri Jan 29, 2010 3:57 pm    Post subject: Yet another URL auth Question Reply with quote

First of all; Hello all and thanks for this piece of software which is brilliant!


I have been playing with Auth by URL but i cannot figure out how to evaluate a condition.

I added the mount settings for url auth and header and name="listener_add" pointing to a php script listener_joined.php

In this script if i put header("header i expect") the music plays.
If i evaluate it against anything it asks for a user name and password.

What i want to do is for the listeners to be tied to my web page in order to listen to the music;

I have not found a way to pass arguments from the embeed code, if as the doc says i use a mount type /music?&Validation=1 when i look in listener_joined.php the validation=1 never arrived... (I think it is expected according to the docs.)

The referer arrives empty also to the script...
So how can pass something from my web page to listener_joined.php to evaluate and then set the header to allow music to play ?

Thanks in advance
N
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Fri Jan 29, 2010 6:06 pm    Post subject: Reply with quote

most players don't pass the referrer header so the url code never checked for it. If you use query args then icecast will escape encode them or else those will get mixed up with the normal POST. So take the mount value and unescape it, then you can split it for the actual values.

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



Joined: 29 Jan 2010
Posts: 4

PostPosted: Fri Jan 29, 2010 6:55 pm    Post subject: Reply with quote

Hello Karl; thanks for replying

karlH wrote:
most players don't pass the referrer header so the url code never checked for it.

I suspected that by looking at my logs

The ICECast log shows the UserAgent
XXX.XXX.XXX.XXX - - [29/Jan/2010:13:08:10 +0100] "GET /autopl HTTP/1.1" 404 106 "-" "NSPlayer/11.0.6002.18049 WMFSDK/11.0" 0

That is me accessing the mount from a web page.

But the logs for the apache where listener_add.php is show only the ip of the ICecast server.

ICECASTServerIP - "" [29/Jan/2010:19:19:39 +0100] "POST /login/listener_joined.php HTTP/1.1" 200 - "-" "Icecast 2.3.2"


karlH wrote:
If you use query args then icecast will escape encode them or else those will get mixed up with the normal POST. So take the mount value and unescape it, then you can split it for the actual values.


There is were i get lost. (Im more the hardware guy thou i have a fair understanding or WEB php and HTML are not my turf.

Can you show me an example on how i should construct the mount name in the embeed for it to arrive to the Icecast servers and be send to Listener_add.php

I have spent most of today looking for a way to do this and google was not my friend; neither trial and error was....

I will really appreciate it

cheers
N
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Fri Jan 29, 2010 8:43 pm    Post subject: Reply with quote

The access log will not show POST details as that is sent after the headers. You'll know that POST details are in the form of tag1=value&tag2=value and you know that one of those tags will be mount for the listener_add trigger. The value cannot be whatever was supplied from the user as that could conflict with the rest of the POST, so icecast has to escaped it, you'll have to un-escape the mount value before checking what the user actually sent.

you should find that in php, the urldecode, explode and split routines will suit your needs.

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



Joined: 29 Jan 2010
Posts: 4

PostPosted: Fri Jan 29, 2010 9:19 pm    Post subject: Reply with quote

So i can not URL Auth when making the call from an embeed object ?

I mean the object has the address in the form

Source="http://myserver.com:port/mount"

I was hoping to be able to verify if the embed object was coming from my page and not from another page or player...

If I understood properly any request on a mount with the auth tags will trigger listeneradd and process the listener_joined.php

i have tried putting a echo $_REQUEST / $_POST $_get even all vars on every script to see how they behave and when icecast calls listener_joined.php is sending it nothing...

I am very confused Very Happy

can i call the auth from an embeed player and expect it to be authed ?

if so; should i add to the address something in the mount name ?
i have tried and adding ?whatever the stream mounts


my icecast.xsl contains for that mount:
Code:
<mount>
Normal mount stuff
        <authentication type="url">
        <option name="listener_add" value="http://domain.com/listener_joined.php"/>
        <option name="auth_header" value="icecast-auth-user: 1"/>
        </authentication>
</mount>



Should i add something to the listener_add line ?
Should i add other lines?

Right now for lack of alternative the contents of listener_joined.php are
Code:
<? header('icecast-auth-user: 1') ?>


I was thinking in the lines of an:

if(something) then header();

just i dont know how to make that something get there.
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Fri Jan 29, 2010 9:51 pm    Post subject: Reply with quote

doesn't matter whether the player is embedded or a standalone player, it still has to issue a request and supply details, icecast won't know it's from a web page specifically. Put another way, If you see a request for a stream, what makes to think it's from an embedded player, referrer?, query args supplied?

The embedded player does not request auth, doing so means it can be bypassed. icecast will issue the ...listener_joined.php request, but will only accept the listener if the expected header (icecast-auth-user: 1) is received back from that php.

The question you need to ask is what do you think is acceptable for a request to be from an embedded object?
eg
GET /stream HTTP/1.0
GET /stream?referrer=www.mywebsite.com HTTP1/.0
GET /stream?session=12345 ....
GET /stream?timecode=....

your php can get this information and make a decision. You may find the referrer acceptable or something mode involved requiring a web portal login to come up with a generate session id in a DB, or maybe something in-between like the timecode which could mean only available for the next minute.

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



Joined: 29 Jan 2010
Posts: 4

PostPosted: Sat Jan 30, 2010 6:45 am    Post subject: Reply with quote

Quote:
The question you need to ask is what do you think is acceptable for a request to be from an embedded object?
eg
GET /stream HTTP/1.0
GET /stream?referrer=www.mywebsite.com HTTP1/.0
GET /stream?session=12345 ....
GET /stream?timecode=....


Thanks Karl; that is exactly where i m stuck...
the GET part... how can I build it in the embed object [/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: Sat Jan 30, 2010 1:26 pm    Post subject: Reply with quote

surely that will depend on the language of the embedded object and how it handles URLs and strings. Maybe you should be asking those questions on a forum suitable for that embedded object? Obviously we cannot give specific advice on such a vague question.

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