normalize_tenant {AzureAuth}R Documentation

Normalize GUID and tenant values

Description

These functions are used by get_azure_token to recognise and properly format tenant and app IDs. is_guid can also be used generically for identifying GUIDs/UUIDs in any context.

Usage

normalize_tenant(tenant)

normalize_guid(x)

is_guid(x)

Arguments

tenant

For normalize_tenant, a string containing an Azure Active Directory tenant. This can be a name ("myaadtenant"), a fully qualified domain name ("myaadtenant.onmicrosoft.com" or "mycompanyname.com"), or a valid GUID.

x

For is_guid, a character string; for normalize_guid, a string containing a validly formatted GUID.

Details

A tenant can be identified either by a GUID, or its name, or a fully-qualified domain name (FQDN). The rules for normalizing a tenant are:

  1. If tenant is recognised as a valid GUID, return its canonically formatted value

  2. Otherwise, if it is a FQDN, return it

  3. Otherwise, if it is one of the generic tenants "common", "organizations" or "consumers", return it

  4. Otherwise, append ".onmicrosoft.com" to it

These functions are vectorised. See the link below for the GUID formats they accept.

Value

For is_guid, a logical vector indicating which values of x are validly formatted GUIDs.

For normalize_guid, a vector of GUIDs in canonical format. If any values of x are not recognised as GUIDs, it throws an error.

For normalize_tenant, the normalized tenant IDs or names.

See Also

get_azure_token

Parsing rules for GUIDs in .NET. is_guid and normalize_guid recognise the "N", "D", "B" and "P" formats.

Examples


is_guid("72f988bf-86f1-41af-91ab-2d7cd011db47")    # TRUE
is_guid("{72f988bf-86f1-41af-91ab-2d7cd011db47}")  # TRUE
is_guid("72f988bf-86f1-41af-91ab-2d7cd011db47}")   # FALSE (unmatched brace)
is_guid("microsoft")                               # FALSE

# all of these return the same value
normalize_guid("72f988bf-86f1-41af-91ab-2d7cd011db47")
normalize_guid("{72f988bf-86f1-41af-91ab-2d7cd011db47}")
normalize_guid("(72f988bf-86f1-41af-91ab-2d7cd011db47)")
normalize_guid("72f988bf86f141af91ab2d7cd011db47")

normalize_tenant("microsoft")     # returns 'microsoft.onmicrosoft.com'
normalize_tenant("microsoft.com") # returns 'microsoft.com'
normalize_tenant("72f988bf-86f1-41af-91ab-2d7cd011db47") # returns the GUID

# vector arguments are accepted
ids <- c("72f988bf-86f1-41af-91ab-2d7cd011db47", "72f988bf86f141af91ab2d7cd011db47")
is_guid(ids)
normalize_guid(ids)
normalize_tenant(c("microsoft", ids))


[Package AzureAuth version 1.3.3 Index]