ansible-collections / azure

Development area for Azure Collections

Home Page:https://galaxy.ansible.com/azure/azcollection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

azure.azcollection.azure_rm_adapplication add option 'reply_urls_with_type'

therapac opened this issue · comments

SUMMARY

It would be very useful if we could provide a type for the 'reply_urls'. We would like to have a 'reply_urls_with_type' (see ADDITIONAL INFORMATION).

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

azure.azcollection.azure_rm_adapplication module

ADDITIONAL INFORMATION
reply_urls:
    description:
        - Space-separated URIs to which Azure AD will redirect in response to an OAuth 2.0 request.
        - The value does not need to be a physical endpoint, but must be a valid URI.
    type: list
    elements: str

# new option
reply_urls_with_type:
    description:
        - Space-separated URIs to which Azure AD will redirect in response to an OAuth 2.0 request.
    type: list
    elements: dict
    suboptions:
        url:
            description:
                - The value does not need to be a physical endpoint, but must be a valid URI.
            type: str
        type:
            description:
                - Each URI value should contain an associated app type value. Supported type values are
                    - "Web"
                    - "InstalledClient"
                    - "Spa"
            type: str
- name: Setting facts so that they will be persisted in the fact cache
  ansible.builtin.set_fact:
    __app_id: "36b5a239-14c8-4a67-23f3-15225b489053"
    __reply_urls:
      - url:  "https://www.test.ch"
        type: "Web"

- name: Create application
  azure.azcollection.azure_rm_adapplication:
    app_id:                 "{{ __app_id }}"
    reply_urls_with_type:   "{{ __adapp.reply_urls }}"

@therapac Welcome to submit your problems! But I checked the SDK that migrated to msgraph and it supports' reply_urls(list/str)', not reply_urls_with_type. Why did you add this parameter?

There are 3 different types (Web, InstalledClient, Spa), currently only the web is being considered. But the other two are also needed.

azure_rm_adapplication.py:

from msgraph.generated.models.application import WebApplication

from msgraph.generated.models.web_application import WebApplication

# New imports
from msgraph.generated.models.public_client_application import SpaApplication
from msgraph.generated.models.spa_application import PublicClientApplication

...

create_app = Application(
    sign_in_audience=self.sign_in_audience,
    web = WebApplication(
        home_page_url=self.homepage,
        redirect_uris=self.reply_urls,
        implicit_grant_settings=ImplicitGrantSettings(
            enable_access_token_issuance=self.oauth2_allow_implicit_flow,
        ),
    ),
# New add SPA
    spa = SpaApplication(
        ...
    ),

# New add PublicClientApplication
    public_client = PublicClientApplication(
        ...
    ),

    display_name=self.display_name,
    identifier_uris=self.identifier_uris,
    key_credentials=key_creds,
    password_credentials=password_creds,
    required_resource_access=required_accesses,
    app_roles=app_roles,
    optional_claims=self.optional_claims
    # allow_guests_sign_in=self.allow_guests_sign_in,
)

@therapac Added in #1494. Thank you very much!

@therapac It can have more than one(spa/public client/ web), so change it this way. Thank you!

I noticed that it only needs one more attribute. Namely reply_urls_type. Since there can only be one type with multiple URLs per application.

I could help rewrite the module.

Just like this picture!
image

You're right, you can mix them :-).