ppatierno / azuresblite

Access to Microsoft Azure Service Bus from all platforms using AMQP protocol
Apache License 2.0
28 stars 10 forks source link

Unauthorized access. 'Listen' claim(s) are required to perform this operation #2

Closed vijayshinvabk closed 9 years ago

vijayshinvabk commented 9 years ago

Trying to receive messages from a Azure Service Bus Topic using a Shared Access Signature.

var topicToken = "SharedAccessSignature sr=sb%3a%2f%2ftestdev.servicebus.windows.net&sig=j****&se=1442125460&skn=Receive";

MessagingFactory mf = MessagingFactory.Create(runtimeUri, TokenProvider.CreateSharedAccessSignatureTokenProvider(topicToken)); var receiveClient = mf.CreateSubscriptionClient(topicName,subscriptionName); var msg = receiveClient.Receive();

But keep getting Unauthorized error messages in the trace [11:27.808] RECV sasl-mechanisms(sasl-server-mechanisms:[PLAIN,EXTERNAL]) [11:27.900] RECV sasl-outcome(code:0,additional-data:57656C636F6D6521)


[11:27.972] RECV AMQP 0 1 0 0 [11:28.060] RECV (ch=0) open(container-id:5ca3fcbab5ae45e5b9bccd079fe958c4_G8,max-frame-size:16384,channel-max:3,idle-time-out:240000) [11:28.060] RECV (ch=0) begin(remote-channel:0,next-outgoing-id:1,incoming-window:2048,outgoing-window:2048,handle-max:7) [11:28.201] RECV (ch=0) attach(name:amqp-receive-link testdev-t/Subscriptions/48835779804448ddac34e632f4f6aed7,handle:0,role:False,initial-delivery-count:0,max-message-size:266240) [11:28.305] RECV (ch=0) detach(handle:0,closed:True,error:error(condition:amqp:unauthorized-access,description:Unauthorized access. 'Listen' claim(s) are required to perform this operation. Resource: 'sb://testdev.servicebus.windows.net/testdev-t/subscriptions/48835779804448ddac34e632f4f6aed7'.

Looks like the TokenProvider.CreateSharedAccessSignatureTokenProvider() with a shared access signature is not working. The same token / topic_subscription using WindowsAzure.ServiceBus nuget works fine. The 'Listen' permissions are granted.

ppatierno commented 9 years ago

Thanks for opening the issue. The current version lacks the claim based authentication on receiver. I'll fix it and add into next release.

Paolo.

vijayshinvabk commented 9 years ago

Thank you.

ppatierno commented 9 years ago

I have just updated the "develop" branch of the project with the feature. You can use it and test if it works in your scenario : a feedback is appreciated so that I'll merge in the "master" branch and will release on Nuget the new package.

Of course, you have to clone the project from GitHub and don't use the current Nuget package that isn't updated (I don't know how you executed above code).

Thanks, Paolo.

ppatierno commented 9 years ago

Just released version 1.2.0 with SAS token support. Paolo.

smattoo commented 9 years ago

Hi,

We see the below error on updating the package to the latest version. This link also states a similar exception https://github.com/aspnet/dnx/issues/526

Missing method System.Net.Sockets.Socket::.ctor(SocketType,ProtocolType) in assembly /usr/lib/mono/gac/System/4.0.0.0b77a5c561934e089/System.dll, referenced in assembly /home/pi/Gateway/IoTNext.Gateway/Amqp.Net.dll 2015-09-16 12:20:09.0927|ERROR|IoTNext.Gateway.Daemon.CloudSubscriber|System.MissingMethodException: Method not found: 'System.Net.Sockets.Socket..ctor'. at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[d5](Amqp.d__5& stateMachine) [0x00000] in :0 at Amqp.TcpTransport.ConnectAsync (Amqp.Address address, Amqp.ConnectionFactory factory) [0x00000] in :0