Project

General

Profile

Tigase 7.1 HTTP API open_access issue

Aejaz Muslim
Added about 2 years ago

Hi,

I have set various api-keys[s] to open_access but I keep getting “To access URI = '/rest/stream/' a valid api key is required” error when I try to post an XML stanza to with Content-Type header set to application/xml to the following URLs,

http://:@dev2.evolko.com:8180/rest/stream/?api_key=open_access"

http://dev2.evolko.com:8180/rest/stream

http://:@dev2.evolko.com:8180/rest/stream/{receiver_JID}

http://dev2.evolko.com:8180/rest/ works but http://dev2.evolko.com:8180/rest/users gives “valid api key required” message. I tried all sorts of combinations in init.properties so that open_access would be recognized by the server by reading the documentation & various forum posts but no luck so far. Can someone please look at my logs & init.properties & let me know what is wrong.

Here is my partial init.properties,

--comp-name-7=http

--comp-class-7=tigase.http.HttpMessageReceiver

http/http/ports[i]=8180

http/rest/active[B]=true

--api-keys[s]=open_access

--http/rest/api-keys[s]=open_access

--rest/stream/api-keys[s]=open_access

#Tried with this also but didn’t work

#--rest/rest/api-key[s]=open_access

Thanks,

Aejaz


Replies (14)

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam about 2 years ago

Have you tried setting open_access in following way in init.properties file:

http/rest/api-keys[s]=open_access

Way to set api-keys is described at Tigase HTTP API project wiki page, see https://projects.tigase.org/projects/tigase-http-api/wiki/Configuration

Added by Aejaz Muslim about 2 years ago

Thanks for your prompt reply. I was using,

--http/rest/api-keys[s]=open_access

I removed "--" from the line & restarted

Tigase. Now it is asking for authentication.

But when I provide the admin username & password,

it is not taking it. Here is what is stored in the

database,

mysql> select user_id, user_pw from tig_users where user_id like '%admin%' ;

+------------+--------------+

| user_id | user_pw |
+------------+--------------+

| admin@dev2 | admin_evolko |
| admin@http | NULL |
+------------+--------------+

2 rows in set (0.10 sec)

I tried giving "admin@dev2" for username(without ") &

password as "admin_evolko" but it is not accepting it.

I removed "@dev2" but that is also not taken. The entry

in init.properties is as follows,

--admins = admin@dev2

Please let me know why it is not taking the password.

Thanks,

Aejaz

Added by Aejaz Muslim about 2 years ago

I also tried removing "@dev2" from the init.properties

entry(i.e. --admins = admin) & restarted it.

Gave the username/password as admin/admin_evolko &

admin@dev2/admin_evolko. It still did not work.

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam about 2 years ago

How you are providing password to HTTP request?

Do you use CURL? a web browser? or something else?

Added by Aejaz Muslim about 2 years ago

I am trying to go to http://dev2.evolko.com:8180/rest/users through browser when authentication pop up is shown but it doesn't go away with any username & password combination.

Additionally I have a java program using which I gave a post request to send a stanza using the link,

http://admin:admin_evolko@dev2.evolko.com:8180/rest/stream

It gives "Not authorized" message.

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam about 2 years ago

With web browser it should work with admin@dev2 and @admin_evolko@.

This configuration should work fine with this credentials as you have admin@dev2 listed in --admins configuration property. (I've checked it few minutes ago)

Please try using --admins=admin@dev2 in config file - same what you already have but without any spaces in this line and restart Tigase XMPP Server.

Added by Aejaz Muslim about 2 years ago

Thanks a lot, I will try & let you know.

Added by Aejaz Muslim about 2 years ago

Unfortunately it still doesn't work. I changed the line in init.properties as

you suggested & restarted tigase but still unable to go past the authentication.

Currently the line in init.properties is as follows,

--admins=admin@dev2

In database I verified that there was no space character added to username & password,

mysql> select user_id, user_pw, length(user_id), length(user_pw) from tig_users where user_id like '%admin%' ;

+------------+--------------+-----------------+-----------------+

| user_id | user_pw | length(user_id) | length(user_pw) |
+------------+--------------+-----------------+-----------------+

| admin@dev2 | admin_evolko | 10 | 12 |
| admin@http | NULL | 10 | NULL |
+------------+--------------+-----------------+-----------------+

2 rows in set (0.05 sec)

You can try this link,

http://dev2.evolko.com:8180/rest/users/

Thanks,

Aejaz

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam about 2 years ago

It is hard to tell what is exactly going wrong. I tried provided link and login failed while I tried 3 different installations with version 7.1.0 deployed and all are working fine.

I would suggest to enable logging for http component by adding http to comma separated list of --debug property and check logs for any reported issues.

Please note that user account may be disabled or inactive and in this case you also will not be able to login.

Added by Aejaz Muslim about 2 years ago

After enabling debug on http I found that it was not able to find the user admin@dev2.

As I had upgraded the database from Tigase 7.0.2 to Tigase 7.1 & it seems that during

update sha1_user_id got somehow corrupted(for admin@dev2) as I had to manually run few

scripts. I changed admin value in init.properties to to another working user_id which

could login successfully to Tigase & I was able to login from the web browser without

any problems.

Thanks again,

Aejaz

Added by 连生 张 7 days ago

If I want to customize the HTTP request interface, how do I do that?

Added by Wojciech Kapcia TigaseTeam 6 days ago

Please create new thread instead of adding message to old thread!

As for your question - what would you like to customise in the interface?

Added by 连生 张 6 days ago

Why is it that when I send a request to add a roster, the other person logs out without doing anything, and when he logs in again, the previous roster request is automatically sent?How can I keep her from sending?

Added by Wojciech Kapcia TigaseTeam 5 days ago

Please create new thread for separate issues: https://tigase.tech/projects/tigase-http-api/boards

    (1-14/14)