Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chgeuer/ex_microsoft_azure_utils
Utilities for authN against Azure Active Directory (AAD)
https://github.com/chgeuer/ex_microsoft_azure_utils
elixir elixir-language elixir-library elixir-programming-language
Last synced: 1 day ago
JSON representation
Utilities for authN against Azure Active Directory (AAD)
- Host: GitHub
- URL: https://github.com/chgeuer/ex_microsoft_azure_utils
- Owner: chgeuer
- License: apache-2.0
- Created: 2019-01-28T11:54:16.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-09-28T14:46:17.000Z (over 3 years ago)
- Last Synced: 2024-11-16T13:13:06.681Z (2 months ago)
- Topics: elixir, elixir-language, elixir-library, elixir-programming-language
- Language: Elixir
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ExMicrosoftAzureManagementSamples
## Sign-in demo
```bash
/mnt/c/Program\ Files\ \(x86\)/Elixir/bin/iex -S mix
``````elixir
#
# Sign in to Storage using Azure AD
#
alias Microsoft.Azure.ActiveDirectory.{DeviceAuthenticator, DeviceAuthenticatorSupervisor}
alias Microsoft.Azure.ActiveDirectory.DeviceAuthenticator.Model.State
alias Microsoft.Azure.Storage
alias Microsoft.Azure.Storage.{Container, Blob, Queue, BlobStorage}storage_account_name = "erlang"
resource = "https://#{storage_account_name}.blob.core.windows.net/"{:ok, storage_pid} = %State{ resource: resource, tenant_id: "chgeuerfte.onmicrosoft.com", azure_environment: :azure_global } |> DeviceAuthenticatorSupervisor.start_link()
storage_pid |> DeviceAuthenticator.get_device_code()
aad_token_provider = fn (_resource) ->
storage_pid |> DeviceAuthenticator.get_token
|> elem(1)
|> Map.get(:access_token)
endaad_token_provider.(resource)
aad_token_provider.(resource) |> JOSE.JWT.peek()
aad_token_provider.(resource) |> JOSE.JWT.peek() |> Map.get(:fields) |> Enum.map( fn({k,v}) -> "#{k |> String.pad_trailing(12, " ")}: #{inspect(v)}" end) |> Enum.join("\n") |> IO.puts()
aad_token_provider.(resource) |> JOSE.JWT.peek() |> Map.get(:fields) |> Map.get("iat")storage_pid |> DeviceAuthenticatorSupervisor.get_state()
storage_pid |> DeviceAuthenticatorSupervisor.get_worker_pid() |> Process.exit(:kill)
```--------------------------
## misc
Currently, I'm having problems POSTing to ARM API: https://github.com/swagger-api/swagger-codegen/issues/8138
- https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#parameterObject
- https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ElixirClientCodegen.java
- https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources/elixir
- https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/elixir/api.mustache#L46
- https://swagger.io/docs/specification/2-0/describing-request-body/```sh
find . -type f -name "*.ex" -exec sed -i'' -e 's/add_param(:body, :"parameters", parameters)/add_param(:body, :body, parameters)/g' {} +
```