This PR exposes the current service principal in the Azure API and provides several improvements to allow APIs interact with the current user information and the different OAuth resources.
* It uses the *Graph RBAC* API to retrieve the current Service Principal. * If binds it to the Guice context to make it injectable as a `Supplier<ServicePrincipal>`. This way it is available where needed (for example in the `KeyVault` classes, to get its `obejctId`). * It also makes the `tenantId` injectable as: `@Tenant String tenantId`. * Provides a generic way to specify custom OAuth resources for APIs classes and concrete API methods. To use a custom OAuth resource in an API call just annotate the API or method with `@OAuthResource("custom resource")` and authentication will automatically use the custom one. @jmspring I think this will be very useful for the KeyVault pull request. Could you give this approach a try? In concrete: * You'll be able to remove the need to ask for the `objectId` in the properties, as now it is automatically resolved and you can inject the service principal supplier wherever you need the `objectId`. * It also allows you to configure the entire KeyVault API with the custom OAuth endpoint annotation for a clean OAuth configuration. You can view, comment on, or merge this pull request online at: https://github.com/jclouds/jclouds-labs/pull/424 -- Commit Summary -- * Injectable current service principal -- File Changes -- M azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java (40) M azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java (20) M azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeHttpApiModule.java (83) A azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureOAuthConfigFactory.java (60) A azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/GraphRBAC.java (35) A azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/OAuthResource.java (35) A azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/Tenant.java (34) A azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ServicePrincipal.java (71) A azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/CurrentServicePrincipalApiLiveTest.java (34) -- Patch Links -- https://github.com/jclouds/jclouds-labs/pull/424.patch https://github.com/jclouds/jclouds-labs/pull/424.diff -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/424