Re: Get current user from outside (George W Langham)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Get current user from outside (George W Langham)

Mamadou Cissé
Do you have the session cookie available in the sub domain ? 
(you can var_dump the $_COOKIE[oc_name] to see what it contains.
where oc_name is the name of your owncloud instance.)
if so, you can have the session id.
Once you got the session id you can know if the user is authenticated. 

MC

Le Vendredi 24 Juin 2016 14:00 CEST, [hidden email] a écrit:
 
Send Devel mailing list submissions to
[hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
http://mailman.owncloud.org/mailman/listinfo/devel
or, via email, send a message with subject or body 'help' to
[hidden email]

You can reach the person managing the list at
[hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Devel digest..."


Today's Topics:

1. Re: Get current user from outside (George W Langham)


----------------------------------------------------------------------

Message: 1
Date: Thu, 23 Jun 2016 16:21:29 +0100
From: George W Langham <[hidden email]>
To: List for Developers of ownCloud <[hidden email]>
Subject: Re: [owncloud-devel] Get current user from outside
Message-ID:
<CANuKeRHet-t=BhDxbJ_ZhQd_NcZOn2u4yHiJfUyfF23=[hidden email]>
Content-Type: text/plain; charset="utf-8"

yes.

On Wed, May 25, 2016 at 7:43 AM, <[hidden email]> wrote:

> Hi all!
>
> I'm wondering if / how I can get the logged in user from another subdomain?
>
> - oC is running on 'sub.myDomain.tld'
> - My script is running on 'another.sub.myDomain.tld'
>
> I tried
>
> chdir('../path/to/oC/'); // it didn't work to require_once() the
> following files directly due to an autoloader exception so I just changed
> the current dir
> require_once 'lib/base.php';
> require_once 'lib/public/user.php';
>
> if( \OCP\User::isLoggedIn())
> {
> $user->username = \OC::$server->getUserSession();
> }
> else
> {
> $user->username = 'NO_USER';
> }
>
> $user->username = \OC::$server->getUserSession()->getUser()->getUID() ;
>
> var_dump($user->username); // string(7) "NO_USER"
>
> I also added the used subdomain as trusted domain in /config/config.php.
> I guess I can't just include /lib/base.php, can I? It works if I try this
> with a file within my oC directory.
>
>
>
> Many thanks in advance!
>
> Stefan
>
> _______________________________________________
> Devel mailing list
> [hidden email]
> http://mailman.owncloud.org/mailman/listinfo/devel
>
>


--
Regards,

George William Langham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.owncloud.org/pipermail/devel/attachments/20160623/3815b797/attachment-0001.html>

------------------------------

_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel


End of Devel Digest, Vol 30, Issue 13
*************************************



 
_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel
Reply | Threaded
Open this post in threaded view
|

Re: Get current user from outside (George W Langham)

Stefan Herzog
Where could I get the name of my oC instance?


Mit freundlichen Grüßen / Yours sincerely

Stefan Herzog

> Am 24.06.2016 um 15:42 schrieb Mamadou Cissé <[hidden email]>:
>
> Do you have the session cookie available in the sub domain ?
> (you can var_dump the $_COOKIE[oc_name] to see what it contains.
> where oc_name is the name of your owncloud instance.)
> if so, you can have the session id.
> Once you got the session id you can know if the user is authenticated.
>
> MC
>
> Le Vendredi 24 Juin 2016 14:00 CEST, [hidden email] a écrit:
>  
>>
>> Send Devel mailing list submissions to
>> [hidden email]
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>> http://mailman.owncloud.org/mailman/listinfo/devel
>> or, via email, send a message with subject or body 'help' to
>> [hidden email]
>>
>> You can reach the person managing the list at
>> [hidden email]
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of Devel digest..."
>>
>>
>> Today's Topics:
>>
>> 1. Re: Get current user from outside (George W Langham)
>>
>>
>> ----------------------------------------------------------------------
>>
>> Message: 1
>> Date: Thu, 23 Jun 2016 16:21:29 +0100
>> From: George W Langham <[hidden email]>
>> To: List for Developers of ownCloud <[hidden email]>
>> Subject: Re: [owncloud-devel] Get current user from outside
>> Message-ID:
>> <CANuKeRHet-t=BhDxbJ_ZhQd_NcZOn2u4yHiJfUyfF23=[hidden email]>
>> Content-Type: text/plain; charset="utf-8"
>>
>> yes.
>>
>> On Wed, May 25, 2016 at 7:43 AM, <[hidden email]> wrote:
>>
>> > Hi all!
>> >
>> > I'm wondering if / how I can get the logged in user from another subdomain?
>> >
>> > - oC is running on 'sub.myDomain.tld'
>> > - My script is running on 'another.sub.myDomain.tld'
>> >
>> > I tried
>> >
>> > chdir('../path/to/oC/'); // it didn't work to require_once() the
>> > following files directly due to an autoloader exception so I just changed
>> > the current dir
>> > require_once 'lib/base.php';
>> > require_once 'lib/public/user.php';
>> >
>> > if( \OCP\User::isLoggedIn())
>> > {
>> > $user->username = \OC::$server->getUserSession();
>> > }
>> > else
>> > {
>> > $user->username = 'NO_USER';
>> > }
>> >
>> > $user->username = \OC::$server->getUserSession()->getUser()->getUID() ;
>> >
>> > var_dump($user->username); // string(7) "NO_USER"
>> >
>> > I also added the used subdomain as trusted domain in /config/config.php.
>> > I guess I can't just include /lib/base.php, can I? It works if I try this
>> > with a file within my oC directory.
>> >
>> >
>> >
>> > Many thanks in advance!
>> >
>> > Stefan
>> >
>> > _______________________________________________
>> > Devel mailing list
>> > [hidden email]
>> > http://mailman.owncloud.org/mailman/listinfo/devel
>> >
>> >
>>
>>
>> --
>> Regards,
>>
>> George William Langham
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: <http://mailman.owncloud.org/pipermail/devel/attachments/20160623/3815b797/attachment-0001.html>
>>
>> ------------------------------
>>
>> _______________________________________________
>> Devel mailing list
>> [hidden email]
>> http://mailman.owncloud.org/mailman/listinfo/devel
>>
>>
>> End of Devel Digest, Vol 30, Issue 13
>> *************************************
>
>
>
>  
> _______________________________________________
> Devel mailing list
> [hidden email]
> http://mailman.owncloud.org/mailman/listinfo/devel

_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel
Reply | Threaded
Open this post in threaded view
|

Re: Get current user from outside (George W Langham)

Stefan Herzog
Okay, I have the name. This cookie isn't available on my subdomain.

Where is this cookie set?


Mit freundlichen Grüßen / Yours sincerely

Stefan Herzog

> Am 01.07.2016 um 08:12 schrieb Stefan Herzog <[hidden email]>:
>
> Where could I get the name of my oC instance?
>
>
> Mit freundlichen Grüßen / Yours sincerely
>
> Stefan Herzog
>
>> Am 24.06.2016 um 15:42 schrieb Mamadou Cissé <[hidden email]>:
>>
>> Do you have the session cookie available in the sub domain ?
>> (you can var_dump the $_COOKIE[oc_name] to see what it contains.
>> where oc_name is the name of your owncloud instance.)
>> if so, you can have the session id.
>> Once you got the session id you can know if the user is authenticated.
>>
>> MC
>>
>> Le Vendredi 24 Juin 2016 14:00 CEST, [hidden email] a écrit:
>>
>>>
>>> Send Devel mailing list submissions to
>>> [hidden email]
>>>
>>> To subscribe or unsubscribe via the World Wide Web, visit
>>> http://mailman.owncloud.org/mailman/listinfo/devel
>>> or, via email, send a message with subject or body 'help' to
>>> [hidden email]
>>>
>>> You can reach the person managing the list at
>>> [hidden email]
>>>
>>> When replying, please edit your Subject line so it is more specific
>>> than "Re: Contents of Devel digest..."
>>>
>>>
>>> Today's Topics:
>>>
>>> 1. Re: Get current user from outside (George W Langham)
>>>
>>>
>>> ----------------------------------------------------------------------
>>>
>>> Message: 1
>>> Date: Thu, 23 Jun 2016 16:21:29 +0100
>>> From: George W Langham <[hidden email]>
>>> To: List for Developers of ownCloud <[hidden email]>
>>> Subject: Re: [owncloud-devel] Get current user from outside
>>> Message-ID:
>>> <CANuKeRHet-t=BhDxbJ_ZhQd_NcZOn2u4yHiJfUyfF23=[hidden email]>
>>> Content-Type: text/plain; charset="utf-8"
>>>
>>> yes.
>>>
>>>> On Wed, May 25, 2016 at 7:43 AM, <[hidden email]> wrote:
>>>>
>>>> Hi all!
>>>>
>>>> I'm wondering if / how I can get the logged in user from another subdomain?
>>>>
>>>> - oC is running on 'sub.myDomain.tld'
>>>> - My script is running on 'another.sub.myDomain.tld'
>>>>
>>>> I tried
>>>>
>>>> chdir('../path/to/oC/'); // it didn't work to require_once() the
>>>> following files directly due to an autoloader exception so I just changed
>>>> the current dir
>>>> require_once 'lib/base.php';
>>>> require_once 'lib/public/user.php';
>>>>
>>>> if( \OCP\User::isLoggedIn())
>>>> {
>>>> $user->username = \OC::$server->getUserSession();
>>>> }
>>>> else
>>>> {
>>>> $user->username = 'NO_USER';
>>>> }
>>>>
>>>> $user->username = \OC::$server->getUserSession()->getUser()->getUID() ;
>>>>
>>>> var_dump($user->username); // string(7) "NO_USER"
>>>>
>>>> I also added the used subdomain as trusted domain in /config/config.php.
>>>> I guess I can't just include /lib/base.php, can I? It works if I try this
>>>> with a file within my oC directory.
>>>>
>>>>
>>>>
>>>> Many thanks in advance!
>>>>
>>>> Stefan
>>>>
>>>> _______________________________________________
>>>> Devel mailing list
>>>> [hidden email]
>>>> http://mailman.owncloud.org/mailman/listinfo/devel
>>>
>>>
>>> --
>>> Regards,
>>>
>>> George William Langham
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL: <http://mailman.owncloud.org/pipermail/devel/attachments/20160623/3815b797/attachment-0001.html>
>>>
>>> ------------------------------
>>>
>>> _______________________________________________
>>> Devel mailing list
>>> [hidden email]
>>> http://mailman.owncloud.org/mailman/listinfo/devel
>>>
>>>
>>> End of Devel Digest, Vol 30, Issue 13
>>> *************************************
>>
>>
>>
>>
>> _______________________________________________
>> Devel mailing list
>> [hidden email]
>> http://mailman.owncloud.org/mailman/listinfo/devel
>
> _______________________________________________
> Devel mailing list
> [hidden email]
> http://mailman.owncloud.org/mailman/listinfo/devel

_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel