Skip to content

Auth API: Add event to message queue when account removes own access to organization #27075

Closed

Description

@severinbeauvais

See #26682 for a discussion of this process and the requirements.

Is your feature request related to a problem? Please describe.
As part of the Digital Business card project, there is a requirement to trigger a credential revocation event when a user/account loses access to an organization.

Describe the solution you'd like
A pub/sub event is pushed onto the message queue as part of the API call responsible for removing access. The event will then be picked-up by the handler responsible for issuing/revoking credentials and trigger the revocation event.

Describe alternatives you've considered
N.A.

Additional context
As output from this, documentation on what event to listen to and what data payload to expect to determine WHO the event is related to would be required.


Refinement:
Two scenarios:

  1. When affiliation is broken
  2. When a team member leaves

contents of message:

  • account number
  • business identifier
  • userID
  • action
  • actioned by

Activity

  1. added
    Dependency
    Entities Team
    connect
    on Apr 7, 2025
  2. severinbeauvais commented on Apr 9, 2025

    @severinbeauvais
    CollaboratorAuthor

    @seeker25 @sandragornall As per 26682, is THIS the right solution, and are you able to work on it? It's blocking the DBC2 team. (In a pinch, the DBC2 could possible work on this ticket but I'm sure you could do it much faster!)

  3. seeker25 commented on Apr 9, 2025

    @seeker25
    Contributor
  4. added
    Pay
    and removed
    connect
    on Apr 9, 2025
  5. JohnamLane commented on Apr 9, 2025

    @JohnamLane
    Collaborator

    @OlgaPotiagalova has confirmed that this is part of DBC phase 2, so Pay needs to implement this queue message this PI. We will pull this in and estimate it.

    A note to consider is that when an affiliation is broken, all users on that account lose access to the business. Our queue message will need to enumerate all the people that should have their DBC revoked for that particular business, or we can send a message about an account and DBC needs to look it up in AUTH. Just wanted to say this so we are all clear that affiliations take place between an account and a business, not an individual and a business. <-- does that sound OK Olga?

  6. OlgaPotiagalova commented on Apr 10, 2025

    @OlgaPotiagalova
    Collaborator

    @JohnamLane, yes, it sounds right to me. Could you please provide estimates. This is a blocker for DBC Phase 2 release planned for the end of Apr. e would appreciate it if your team could help address this as soon as possible. Thank you.

  7. seeker25 commented on Apr 10, 2025

    @seeker25
    Contributor

    It's a couple hours work if the PUBSUB topic / subscription already exists. If it doesn't exist maybe a day or less to get it setup and done.

    We'll need clear requirements for it though (exactly when to send the message).

    What is the payload of the expected message? (probably the orgId / status?, might need a little discussion)
    What are the exact business requirements for this message to be sent?
    Which service is it hitting? Is there an existing pathway inside of here:
    https://www.figma.com/file/ZLlmaQ5sCsBEkUxUtsETwQ/PUB%2FSUB-Queue-Mapping?type=whiteboard&node-id=0-1&t=b5mNV4giEuTJU28E-0

    or is it something new? (New Topic, new subscription)

  8. esune commented on Apr 11, 2025

    @esune
    Member

    I'll let @severinbeauvais and @thorwolpert chime in since I am not an expert about Registries' pub/sub architecture and existing setup.

    From a requirement perspective, we need to pick up a notification when an account loses access to an organization. The payload needs to contain enough information to determine which account and organization the notification relates to - extra information may be useful, but that is the bare minimum.

    If I understand things right this will be a new topic/subscription, it does not necessarily need to be specific to DBC though since this type of event may come in handy for other account-related triggers (possibly?).

  9. thorwolpert commented on Apr 11, 2025

    @thorwolpert
    Collaborator

    @esune we have specific subscriptions per service if we want to know if the service is actioning the message, if not they go to a DLQ for some intervention. We do have open topics/subscriptions along the lines of, if you don't process it, it's not a worry.
    We use CloudEvents as the envelope and put just enough data into the message that we can discern if we're interested in doing more with the event.
    You'll have a better idea of what you need, but in order for Travis to bang this out we'll need to know what elements to add.
    eg.

    "data": {
        "identifier": "BC1234567",
        "accountId": "12345",
        "userId": ".......",
        "action": "granted"
    }

    If you wanted to know more, because the elements contained warranted action, you can hit the API for further details.

  10. esune commented on Apr 15, 2025

    @esune
    Member

    Circling back, I am not sure whether more information is needed to move forward, or we are just waiting for this to be scheduled/tackled - please let me know if you need me, a quick chat might be best as I am still familiarizing with the overall architecture/system.

  11. severinbeauvais commented on Apr 15, 2025

    @severinbeauvais
    CollaboratorAuthor

    in order for Travis to bang this out we'll need to know what elements to add

    Emiliano, can you answer this?

  12. esune commented on Apr 15, 2025

    @esune
    Member

    in order for Travis to bang this out we'll need to know what elements to add

    Emiliano, can you answer this?

    I got an invite from @JohnamLane for thursday, I think we will sort this out then - I will likely have questions on what is available to be exposed as well.

  13. JohnamLane commented on Apr 17, 2025

    @JohnamLane
    Collaborator
  14. esune commented on Apr 23, 2025

    @esune
    Member

    @JohnamLane following-up on this to see if your team can provide us with some documentation/examples for the pub/sub APis and possibly mock data so we can start working on our end while we wait for the change to be developed/deployed for final end-to-end validation.

  15. ochiu commented on Apr 25, 2025

    @ochiu
    Collaborator

    @esune

    Some general pub/sub guide information
    https://cloud.google.com/pubsub/docs/publish-receive-messages-client-library

    We are using this sbc common lib for connecting to the gcp queue
    https://github.com/bcgov/sbc-connect-common/tree/main/python/gcp-queue

    This is our queue publisher helper in pay-api
    https://github.com/bcgov/sbc-pay/blob/main/pay-api/src/pay_api/services/gcp_queue_publisher.py

    Here is some reference code on how messages are received and data retrieved from the message
    https://github.com/bcgov/sbc-auth/blob/main/queue_services/auth-queue/src/auth_queue/resources/worker.py

  16. self-assigned this
    on May 2, 2025
  17. added theissue type on May 5, 2025
  18. ochiu commented on May 12, 2025

    @ochiu
    Collaborator

    Some example messages:

    {"data": {"accountId": 3727, "actionedBy": 5751, "actionCategory": "account-management", "businessIdentifier": "BC0887890", "userIds": [5853]}, "datacontenttype": "application/json", "id": "204372f6-6265-4236-bbc4-94e564b4804b", "source": "auth-api", "specversion": "1.0", "subject": null, "time": "2025-05-12T15:07:31.855954+00:00", "type": "bc.registry.auth.businessUnaffiliated"}

    {"data": {"accountId": 3727, "actionedBy": 5751, "actionCategory": "account-management", "businessIdentifier": "BC0887890", "userIds": [5853]}, "datacontenttype": "application/json", "id": "36e8d3d1-3ce6-4221-b180-4af97adf72ac", "source": "auth-api", "specversion": "1.0", "subject": null, "time": "2025-05-12T15:07:44.203476+00:00", "type": "bc.registry.auth.businessAffiliated"}

    {"data": {"accountId": 3141, "actionedBy": 5853, "actionCategory": "account-management", "businessIdentifier": null, "userIds": [5853]}, "datacontenttype": "application/json", "id": "97fe5203-5f8a-4f5d-b109-7759e82b1f3e", "source": "auth-api", "specversion": "1.0", "subject": null, "time": "2025-05-12T15:10:42.659630+00:00", "type": "bc.registry.auth.teamMemberRemoved"}

    I just set up a test subscriber to make sure the messages were received, once we know the endpoint URL for the DBC listener we can set it up so it starts getting messages pushed to it.

  19. JohnamLane commented on May 13, 2025

    @JohnamLane
    Collaborator

    @esune and @lorriewright (in Olga's absence) This is in QA now. I will signal when it's ready to use in Test for the DBC project.

  20. seeker25 commented on May 13, 2025

    @seeker25
    Contributor

    This is feature flagged (DEV/TEST only for now, no prod)

  21. severinbeauvais commented on May 13, 2025

    @severinbeauvais
    CollaboratorAuthor

    Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

DBC Phase 2DependencyEntities TeamPay

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions