Possibility of relaxing email_verified requirement for OIDC

Hi @orne

I have tried N different variations and been in contact with several support staff and raised a support ticket with Microsoft themselves to try and approach this issue, but it seems in the whole of Azure it is simply not possible in the current framework to pass a value as anything other than a string even if it’s defined as a Boolean.

Would it be possible in Golang to interpret a variable from 1 of many sources?
I have the below, which I found several weeks ago, that would expect to receive and parse a boolean from a string, but I have read that an actual boolean would fail on this point.

Is there any version of this that would allow multiple potential sources so as to not impact the way the app currently functions? Eg ‘any’ in angular that is a fully dynamic type.

image

something like EmailVerified bool json:"email_verified,string,bool,omitempty"

Need to add some tests, but I think something like this could work.

type User struct {
	ExternalID     string                 `json:"sub"`
	Name           string                 `json:"name"`
	Email          string                 `json:"email"`
	EmailVerified  bool                   `json:"email_verified"`
	UserInfoClaims map[string]interface{} `json:"user_info_claims"`
}

func (u *User) UnmarshalJSON(data []byte) error {
	tmp := &struct {
		ExternalID     string                 `json:"sub"`
		Name           string                 `json:"name"`
		Email          string                 `json:"email"`
		EmailVerified  interface{}            `json:"email_verified"`
		UserInfoClaims map[string]interface{} `json:"user_info_claims"`
	}{}

	if err := json.Unmarshal(data, &tmp); err != nil {
		return err
	}

	u.ExternalID = tmp.ExternalID
	u.Name = tmp.Name
	u.Email = tmp.Email
	u.UserInfoClaims = tmp.UserInfoClaims

	switch v := tmp.EmailVerified.(type) {
	case string:
		t, err := strconv.ParseBool(v)
		if err != nil {
			return err
		}
		u.EmailVerified = t
	case bool:
		u.EmailVerified = v
	}

	return nil
}
1 Like

Needs some comments and a test-case.

1 Like

Hi is great, thanks for opening a pull request!
This looks to be exactly what I was thinking, but didn’t know how to do it as Go is not my language.

Really appreciate this.