Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azuread_application: support for "myapp://auth" as a public client redirect URI, to support B2C IEF applications #607

Merged
merged 2 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/services/applications/application_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ func applicationResource() *schema.Resource {
MaxItems: 256,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateDiagFunc: validate.IsRedirectUriFunc(false),
ValidateDiagFunc: validate.IsRedirectUriFunc(false, true),
},
},
},
Expand Down Expand Up @@ -447,7 +447,7 @@ func applicationResource() *schema.Resource {
MaxItems: 256,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateDiagFunc: validate.IsRedirectUriFunc(false),
ValidateDiagFunc: validate.IsRedirectUriFunc(false, false),
},
},
},
Expand Down Expand Up @@ -503,7 +503,7 @@ func applicationResource() *schema.Resource {
MaxItems: 256,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateDiagFunc: validate.IsRedirectUriFunc(true),
ValidateDiagFunc: validate.IsRedirectUriFunc(true, false),
},
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ resource "azuread_application" "test" {

public_client {
redirect_uris = [
"myapp://auth",
"https://login.microsoftonline.com/common/oauth2/nativeclient",
"https://login.live.com/oauth20_desktop.srf",
"ms-appx-web://Microsoft.AAD.BrokerPlugin/00000000-1111-1111-1111-222222222222",
Expand Down
7 changes: 6 additions & 1 deletion internal/validate/uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ func IsLogoutUrl(i interface{}, path cty.Path) (ret diag.Diagnostics) {
return
}

func IsRedirectUriFunc(urnAllowed bool) schema.SchemaValidateDiagFunc {
func IsRedirectUriFunc(urnAllowed bool, publicClient bool) schema.SchemaValidateDiagFunc {
return func(i interface{}, path cty.Path) (ret diag.Diagnostics) {
// See https://docs.microsoft.com/en-us/azure/active-directory-b2c/tutorial-create-user-flows?pivots=b2c-custom-policy#register-the-proxyidentityexperienceframework-application
if publicClient && i.(string) == "myapp://auth" {
return
}

ret = IsUriFunc([]string{"http", "https", "ms-appx-web"}, urnAllowed, true)(i, path)
if len(ret) > 0 {
return
Expand Down