Skip to main content

#Authentication0 personne en discute

Maybe you can help us to understand how to approach this use case: as global feature we need to create an endpoint to get the invoices (i.e. GET /invoices), this endpoint needs to be available for several countries (Italy, France, etc…) and we need to make sure each country is able to access ONLY to its invoices.

The API needs to be protected with OAuth2.0, so first step is to authenticate towards the OAuth provider (with client-id and client-secret), get the token back and use the token to invoke the API. Each country will have its pair of client-id and client-secret.

The problem is that once the API received the request (with token), it doesn't know from which user (client-id) is coming from.

How can I make sure that a country can access only its invoices? (i.e. GET endpoint /france/invoices should be available only for France, /germany/invoice should be available only for Germany, etc... )

Thanks a lot!

9 réponses
  1. 30 août 2021, 10:18

    May be expose your API on GET /invoices and GET /invoices/{country} (where "country" can be country name or country code passed as a URI parameter). Then once you receive the request, parse the request ofr the URI Parameter, and once you know what that country name is, modify your query (assuming the invoices are stored in a DB) to pull only records for that country. If the invoices are not in a Database, and if you created a set of separate functions (flows) for each country, then in the main flow you will end up using a Choice-Router to route the requests to appropriate flow based on that country name. Although the secnd option may be really ugly since there are so many countries and your Choice Router will end up with too many paths. My 2 cents

0/9000

The documentation variously says the claims in a JWT are accessible via "#var.claimSet" and also "#authentication.properties.claims". Which is correct, and what's the difference? I can only seem to get authentication.properties.claims to work, where my claim is a list and I use a claim expression such as "#authentication.properties.claims.groups contains 'GroupA'".

4 réponses
  1. 18 sept. 2019, 23:42

    No, I haven't tried that.

0/9000