This is the last part of my 3-part blog series on the recently released Service Bus preview features

[This post series is based on preview features that are subject to change]

part 1: Message Pump

part 2: Auto-expiration

Queue/Subscription Shared Access Authorization

Service Bus uses Windows Azure AD Access Control (a.k.a. Access Control Service or ACS) for authentication. And it uses claims generated by ACS for authorizations. For each Service Bus namespace, there’s a corresponding ACS namespace of the same name (suffixed with “-sb”). In this ACS namespace, there’s a “owner” server identity, for which ACS issues three net.windows.servicebus.action claims with values Manage, Listen, and Send. These claims are in turn used by Service Bus to authorize user for different operations. Because “owner” comes with all three claims, he is entitled to perform any operations that are allowed by Service Bus. I wrote a blog article talking about why it’s a good practice to create additional server identities with minimum access rights - these additional identities can only perform a limited set of operations that are designated to them.

However, there are still two problems: first, by default the security scope of these claims are global to the namespace. For example, once a user is granted Listen access, he can listen to any queues and subscriptions. If you want granular access control at entity level, you’ll need to create additional Relying Parties with entity paths as realms, and a “longest prefix match” policy is applied when authorization is performed (see this doc). Second, identity management is cumbersome as you have to go through ACS and manage service identities.  With Service Bus preview features, you’ll be able to create authorization rules by users or clients. And because you can apply multiple authorization rules, you can manage end user access rights separately even if they share the same queue or subscription. This design gives you great flexibility in managing access rights.

Now let’s walk through a sample to see how that works. In this scenario I’ll create two queues for three users: Tom, Jack, and an administrator. Tom has send/listen access to the first queue. Jack has send/listen access to the second queue. In addition, he can also receive messages from the first queue. The administrator can manage both queues. Their access rights are summarized in the following table:

User Queue 1 Queue 2
Tom Listen/Send No access
Jack Listen only Listen/Send
Admin Manage Manage
  1. Create a new Windows Console application.
  2. Install the preview NuGet package:
    install-package ServiceBus.Preview
  3. Implement the Main() method:
    static void Main(string[] args)
    {
      var queuePath1 = "sasqueue1";
      var queuePath2 = "sasqueue2";
    
      NamespaceManager nm = new NamespaceManager(
        ServiceBusEnvironment.CreateServiceUri("https", "[Your SB namespace]", string.Empty),
        TokenProvider.CreateSharedSecretTokenProvider("owner", "[Your secret key]"));
    
      QueueDescription desc1 = new QueueDescription(queuePath1);
      QueueDescription desc2 = new QueueDescription(queuePath2);
    
      desc1.Authorization.Add(new SharedAccessAuthorizationRule("ForTom", "pass@word1", new AccessRights[] { AccessRights.Listen, AccessRights.Send }));
                
      desc2.Authorization.Add(new SharedAccessAuthorizationRule("ForJack", "pass@word2", new AccessRights[] { AccessRights.Listen, AccessRights.Send }));
      desc2.Authorization.Add(new SharedAccessAuthorizationRule("ForJack", "pass@word2", new AccessRights[] { AccessRights.Listen }));
                
      desc1.Authorization.Add(new SharedAccessAuthorizationRule("ForAdmin", "pass@word3", new AccessRights[] { AccessRights.Manage }));
      desc2.Authorization.Add(new SharedAccessAuthorizationRule("ForAdmin", "pass@word3", new AccessRights[] { AccessRights.Manage }));
    
      nm.CreateQueue(desc1);
      nm.CreateQueue(desc2);
    }

Okay, that’s not the most exciting code. But it should be fairly easy to understand. For each queue I’m attaching multiple SharedAccessAuthorizationRule, in which I can specify the shared key, as well as assigned rights associated with the rule. And I have implemented desired security policy with few lines of code. These entity-level keys have several advantages (comparing to the two problems stated above): first, they provide fine-granular user access control. Second, they are easier to manage. And third, when they are compromised,  the damage can be constrained within the scope of affected entity or even affected user only.

This concludes my 3-part blog series on Service Bus preview features. Many thanks to Abhishek Lal for help and guidance on the way, and to the friends on Twitter who helped to get the words out. Thank you for reading!

0

Add a comment

When we learn classic compute algorithms, we don't start with learning how a computer is built. We don't start with how a transistor works or how to build integrated circuits. Instead, we go straight with the abstraction - bits, commands, programs and such. I think we should take the same approach when we learn quantum computing. Instead of trying to understand the bizarre quantum world, we should take some quantum behaviors granted and go straight with higher-level abstracts such as qubits and quantum gates. And once we grasp these basic concepts, we should go even a level higher to use a high-level language like Q# and focus on how quantum algorithms work, and how we can apply quantum algorithms on practical problems.

Bono is an open source quantum algorithm visualizer I'm building in the open. This project is inspired by a few existing systems such as QuirkIBM Q Experience, and the Programming Quantum Computers book. Bono is a Javascript-based visualizer that features:

  • Drag-and-drop quantum circuit editing.
  • Dynamic circuit evaluation.
  • Works offline in a browser. No server is needed.
  •  Generates Q# code.
I've also created a YouTube channel dedicated to quantum algorithms. My goal is to create an easily digestable course for regular software developers to learn about quantum computing without needing to understand any underlying quantum physics. 

Bono is at its infancy. And I'm still a new student in the quantum world. I intentionally develop both Bono and the video series in the open. I hope the early results can inspire collaborations so that we can explore the quantum computing world together.

Last but not least, you can find more Q# related contents at the Q# Advent Calendar 2019.
0

Add a comment

Series
存档
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.