REST queries: "Read permissions needed"
Tuesday, 8 July 2014 · 9 messages · last reply 25 Nov 2014
JC
Jérôme Chauveau8 Jul 2014 15:20 #
Hi,
i am using BaseX79 as a webapp - embedded in a tomcat7 server.
I am working on a php application which runs REST xqueries to my BaseX server.
I created a "mydb" database and a user "myuser". Then i granted READ permissions for "myuser".
Quoted text · 3 lines
> *GRANT read TO myuser* > *GRAND read TO myuser ON mydb* > *show users*
Username Read Write Create Admin
------------------------------------
admin X X X X
myuser X
Quoted text · 1 line
> *show users on mydb*
Username Read Write
---------------------
myuser X
All my REST xqueries returns a "READ permission needed." message with the user "myuser" when its works properly with the admin user account. Moreover, REST xqueries via a web browser (logged as 'myuser') works properly too.
Did i miss something?
Thank's for help.
Jérôme.
--
Jérôme Chauveau - SAIC-CERTIC - Campus 4
Université de Caen Basse-Normandie
CG
Christian Grün9 Jul 2014 12:39 #
Hi Jérôme,
I tried to simulate your scenario (thanks for giving all the details), but I didn't get a permission error. However, I only tried the basexhttp script and not tomcat. Did you try to to copy .basexperm into the server root or the WAR file [1]?
Best,
Christian
[1] http://docs.basex.org/wiki/Web_Application#User_Management
Quoted text · Jérôme Chauveau · 39 lines
On Tue, Jul 8, 2014 at 3:20 PM, Jérôme Chauveau <jerome.chauveau at unicaen.fr> wrote: > Hi, > > i am using BaseX79 as a webapp - embedded in a tomcat7 server. > > I am working on a php application which runs REST xqueries to my BaseX > server. > I created a "mydb" database and a user "myuser". Then i granted READ > permissions for "myuser". > >> GRANT read TO myuser >> GRAND read TO myuser ON mydb > >> show users > Username Read Write Create Admin > ------------------------------------ > admin X X X X > myuser X > > > show users on mydb > Username Read Write > --------------------- > myuser X > > All my REST xqueries returns a "READ permission needed." message with the > user "myuser" when its works properly with the admin user account. > Moreover, REST xqueries via a web browser (logged as 'myuser') works > properly too. > > Did i miss something? > > Thank's for help. > > Jérôme. > > -- > Jérôme Chauveau - SAIC-CERTIC - Campus 4 > Université de Caen Basse-Normandie
JC
Jérôme Chauveau17 Nov 2014 13:44 #
Hi Christian,
I am sorry for the delay.
I solved my problem with a new tomcat + basex installation/deployment.
But a new one appears now :-)
With this user configuration:
Quoted text · Christian Grün · 1 line
> Username Read Write Create Admin
------------------------------------
admin X X X X
myuser
Quoted text · Christian Grün · 1 line
> show users on mydb
Username Read Write
---------------------
myuser X
=>*i don't want to grant my user with read permission on all databases, only on "mydb" one.*
I always get a "read permission needed" with this kind of query (my db contains xml-tei documents):
[A] = http://localhost:8080/BaseX79/rest/mydb/*mydoc.xml?query=//*:p[1]*
when these one works fine:
[B] = http://localhost:8080/BaseX79/rest/mydb?*query=doc('mydoc.xml')//*:p[1]*
Why?
The query [A] works fine when i set the gobal permissions with:
Quoted text · Christian Grün · 1 line
> Username Read Write Create Admin
------------------------------------
admin X X X X
myuser X
=> As i said previously, i don't want to grant my user with read permission on all databases.
Do i have to always build my queries like doc('mydoc.xml')/xpath to avoid read permission errors?
Thank you.
Best,
Jérôme
Quoted text · Christian Grün · 52 lines
Le 09/07/2014 12:39, Christian Grün a écrit : > Hi Jérôme, > > I tried to simulate your scenario (thanks for giving all the details), > but I didn't get a permission error. However, I only tried the > basexhttp script and not tomcat. Did you try to to copy .basexperm > into the server root or the WAR file [1]? > > Best, > Christian > > [1] http://docs.basex.org/wiki/Web_Application#User_Management > > > On Tue, Jul 8, 2014 at 3:20 PM, Jérôme Chauveau > <jerome.chauveau at unicaen.fr> wrote: >> Hi, >> >> i am using BaseX79 as a webapp - embedded in a tomcat7 server. >> >> I am working on a php application which runs REST xqueries to my BaseX >> server. >> I created a "mydb" database and a user "myuser". Then i granted READ >> permissions for "myuser". >> >>> GRANT read TO myuser >>> GRAND read TO myuser ON mydb >>> show users >> Username Read Write Create Admin >> ------------------------------------ >> admin X X X X >> myuser X >> >> > show users on mydb >> Username Read Write >> --------------------- >> myuser X >> >> All my REST xqueries returns a "READ permission needed." message with the >> user "myuser" when its works properly with the admin user account. >> Moreover, REST xqueries via a web browser (logged as 'myuser') works >> properly too. >> >> Did i miss something? >> >> Thank's for help. >> >> Jérôme. >> >> -- >> Jérôme Chauveau - SAIC-CERTIC - Campus 4 >> Université de Caen Basse-Normandie
--
Jérôme Chauveau - SAIC-CERTIC - Campus 4
Université de Caen Basse-Normandie
CG
Christian Grün17 Nov 2014 18:46 #
Dear Jérôme,
Quoted text · Jérôme Chauveau · 1 line
> I solved my problem with a new tomcat + basex installation/deployment.
Good news!
Quoted text · Jérôme Chauveau · 4 lines
> I always get a "read permission needed" with this kind of query (my db > contains xml-tei documents): > > [A] = http://localhost:8080/BaseX79/rest/mydb/mydoc.xml?query=//*:p[1]
Thanks for reporting this. I did some testing, and you are completely right, this is a bug. I will give you a note once this is fixed.
Christian
CG
Christian Grün17 Nov 2014 21:23 #
Hi Jérôme,
the strange behavior you encountered should be fixed in the latest snapshot [1].
Looking forward to your feedback,
Christian
[1] http://files.basex.org/releases/latest/
Quoted text · Christian Grün · 17 lines
On Mon, Nov 17, 2014 at 6:46 PM, Christian Grün <christian.gruen at gmail.com> wrote: > Dear Jérôme, > >> I solved my problem with a new tomcat + basex installation/deployment. > > Good news! > >> I always get a "read permission needed" with this kind of query (my db >> contains xml-tei documents): >> >> [A] = http://localhost:8080/BaseX79/rest/mydb/mydoc.xml?query=//*:p[1] > > Thanks for reporting this. I did some testing, and you are completely > right, this is a bug. I will give you a note once this is fixed. > > Christian
JC
Jérôme Chauveau18 Nov 2014 10:23 #
Hi Christian,
Perfectly fixed apparently!
Thank you so much for your responsiveness.
Do you know when the next BaseX official released will be available?
Regards,
Jérôme.
Quoted text · Christian Grün · 27 lines
Le 17/11/2014 21:23, Christian Grün a écrit : > Hi Jérôme, > > the strange behavior you encountered should be fixed in the latest snapshot [1]. > > Looking forward to your feedback, > Christian > > [1] http://files.basex.org/releases/latest/ > > > > On Mon, Nov 17, 2014 at 6:46 PM, Christian Grün > <christian.gruen at gmail.com> wrote: >> Dear Jérôme, >> >>> I solved my problem with a new tomcat + basex installation/deployment. >> Good news! >> >>> I always get a "read permission needed" with this kind of query (my db >>> contains xml-tei documents): >>> >>> [A] = http://localhost:8080/BaseX79/rest/mydb/mydoc.xml?query=//*:p[1] >> Thanks for reporting this. I did some testing, and you are completely >> right, this is a bug. I will give you a note once this is fixed. >> >> Christian
--
Jérôme Chauveau - SAIC-CERTIC - Campus 4
Université de Caen Basse-Normandie
CG
Christian Grün18 Nov 2014 15:34 #
Hi Jérôme,
Quoted text · Jérôme Chauveau · 1 line
> Do you know when the next BaseX official released will be available?
Our plan is to align the 8.0 release with the XMLPrague 2015 conference (Feb 13-15).
Keeping our fingers crossed…
Christian
Quoted text · Jérôme Chauveau · 48 lines
On Tue, Nov 18, 2014 at 10:23 AM, Jérôme Chauveau <jerome.chauveau at unicaen.fr> wrote: > Hi Christian, > > Perfectly fixed apparently! > Thank you so much for your responsiveness. > > Regards, > Jérôme. > Le 17/11/2014 21:23, Christian Grün a écrit : > >> Hi Jérôme, >> >> the strange behavior you encountered should be fixed in the latest >> snapshot [1]. >> >> Looking forward to your feedback, >> Christian >> >> [1] http://files.basex.org/releases/latest/ >> >> >> >> On Mon, Nov 17, 2014 at 6:46 PM, Christian Grün >> <christian.gruen at gmail.com> wrote: >>> >>> Dear Jérôme, >>> >>>> I solved my problem with a new tomcat + basex installation/deployment. >>> >>> Good news! >>> >>>> I always get a "read permission needed" with this kind of query (my db >>>> contains xml-tei documents): >>>> >>>> [A] = http://localhost:8080/BaseX79/rest/mydb/mydoc.xml?query=//*:p[1] >>> >>> Thanks for reporting this. I did some testing, and you are completely >>> right, this is a bug. I will give you a note once this is fixed. >>> >>> Christian > > > > -- > Jérôme Chauveau - SAIC-CERTIC - Campus 4 > Université de Caen Basse-Normandie >
JC
Jérôme Chauveau24 Nov 2014 14:20 #
Hi,
May be a new bug relative to the previous one:
My database "db" stores a "mydoc.xml" document.
I get 2 differents response with those 2 supposed equivalent queries (unless I am
mistaken)<http://dictionary.reverso.net/english-french/unless%20I%20am%20mistaken>:
1 - http://localhost:8080/BaseX80/rest?*query=doc('db/mydoc.xml')//*:person* -> these one returns the expected result
2- http://localhost:8080/BaseX80/rest/*db?query=doc('mydoc.xml')//*:person* -> Returns an error:
Stopped at /var/lib/tomcat7/webapps/BaseX80, 1/5: [FODC0002] Resource '/var/lib/tomcat7/webapps/BaseX80/mydoc.xml' does not exist.
Is it a bug?
I am working with the snasphot BaseX80-20141117.211706
Thank you.
Jérôme
Quoted text · Christian Grün · 56 lines
Le 18/11/2014 15:34, Christian Grün a écrit : > Hi Jérôme, > >> Do you know when the next BaseX official released will be available? > Our plan is to align the 8.0 release with the XMLPrague 2015 > conference (Feb 13-15). > > Keeping our fingers crossed… > Christian > > > > On Tue, Nov 18, 2014 at 10:23 AM, Jérôme Chauveau > <jerome.chauveau at unicaen.fr> wrote: >> Hi Christian, >> >> Perfectly fixed apparently! >> Thank you so much for your responsiveness. >> >> Regards, >> Jérôme. >> Le 17/11/2014 21:23, Christian Grün a écrit : >> >>> Hi Jérôme, >>> >>> the strange behavior you encountered should be fixed in the latest >>> snapshot [1]. >>> >>> Looking forward to your feedback, >>> Christian >>> >>> [1] http://files.basex.org/releases/latest/ >>> >>> >>> >>> On Mon, Nov 17, 2014 at 6:46 PM, Christian Grün >>> <christian.gruen at gmail.com> wrote: >>>> Dear Jérôme, >>>> >>>>> I solved my problem with a new tomcat + basex installation/deployment. >>>> Good news! >>>> >>>>> I always get a "read permission needed" with this kind of query (my db >>>>> contains xml-tei documents): >>>>> >>>>> [A] = http://localhost:8080/BaseX79/rest/mydb/mydoc.xml?query=//*:p[1] >>>> Thanks for reporting this. I did some testing, and you are completely >>>> right, this is a bug. I will give you a note once this is fixed. >>>> >>>> Christian >> >> >> -- >> Jérôme Chauveau - SAIC-CERTIC - Campus 4 >> Université de Caen Basse-Normandie >>
--
Jérôme Chauveau - SAIC-CERTIC - Campus 4
Université de Caen Basse-Normandie
CG
Christian Grün25 Nov 2014 18:35 #
Hi Jérôme,
by looking at the queries of your previous mail…
[A] = http://localhost:8080/BaseX79/rest/mydb/mydoc.xml?query=//*:p[1] [B] = http://localhost:8080/BaseX79/rest/mydb?query=doc('mydoc.xml')//*:p[1]
I noticed that Query [B] will never work with the default settings. The reason is that the argument of the doc() function is resolved against the file system, or (if this does not yield results) interpreted as database path [1]. However, you can change this behavior by setting the
DEFAULTDB option [2].
In the REST world, I would indeed recommend you to specify the addressed document in the URL path component, as you did in the first query.
Hope this helps,
Christian
[1] http://docs.basex.org/wiki/Databases#XML_Documents
[2] http://docs.basex.org/wiki/Options#DEFAULTDBQuoted text · Jérôme Chauveau · 8 lines
On Mon, Nov 24, 2014 at 2:20 PM, Jérôme Chauveau <jerome.chauveau at unicaen.fr> wrote: > Hi, > > May be a new bug relative to the previous one: > > My database "db" stores a "mydoc.xml" document. > I get 2 differents response with those 2 supposed equivalent queries
(unless
Quoted text · Jérôme Chauveau · 86 lines
> I am mistaken): > > 1 - http://localhost:8080/BaseX80/rest?query=doc('db/mydoc.xml')//*:person > -> these one returns the expected result > > 2- http://localhost:8080/BaseX80/rest/db?query=doc('mydoc.xml')//*:person > -> Returns an error: > Stopped at /var/lib/tomcat7/webapps/BaseX80, 1/5: [FODC0002] > Resource '/var/lib/tomcat7/webapps/BaseX80/mydoc.xml' does not exist. > > Is it a bug? > > I am working with the snasphot BaseX80-20141117.211706 > > Thank you. > > Jérôme > > > Le 18/11/2014 15:34, Christian Grün a écrit : > > Hi Jérôme, > > Do you know when the next BaseX official released will be available? > > Our plan is to align the 8.0 release with the XMLPrague 2015 > conference (Feb 13-15). > > Keeping our fingers crossed… > Christian > > > > On Tue, Nov 18, 2014 at 10:23 AM, Jérôme Chauveau > <jerome.chauveau at unicaen.fr> wrote: > > Hi Christian, > > Perfectly fixed apparently! > Thank you so much for your responsiveness. > > Regards, > Jérôme. > Le 17/11/2014 21:23, Christian Grün a écrit : > > Hi Jérôme, > > the strange behavior you encountered should be fixed in the latest > snapshot [1]. > > Looking forward to your feedback, > Christian > > [1] http://files.basex.org/releases/latest/ > > > > On Mon, Nov 17, 2014 at 6:46 PM, Christian Grün > <christian.gruen at gmail.com> wrote: > > Dear Jérôme, > > I solved my problem with a new tomcat + basex installation/deployment. > > Good news! > > I always get a "read permission needed" with this kind of query (my db > contains xml-tei documents): > > [A] = http://localhost:8080/BaseX79/rest/mydb/mydoc.xml?query=//*:p[1] > > Thanks for reporting this. I did some testing, and you are completely > right, this is a bug. I will give you a note once this is fixed. > > Christian > > > -- > Jérôme Chauveau - SAIC-CERTIC - Campus 4 > Université de Caen Basse-Normandie > > > > -- > Jérôme Chauveau - SAIC-CERTIC - Campus 4 > Université de Caen Basse-Normandie
Written for BaseX 7.9. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery