Ejemplo n.º 1
0
        private void OAuthDownPartyViewModelAfterInit(GeneralOAuthDownPartyViewModel oauthDownParty, OAuthDownPartyViewModel model)
        {
            if (oauthDownParty.CreateMode)
            {
                if (oauthDownParty.SubPartyType == OAuthSubPartyTypes.Resource)
                {
                    oauthDownParty.EnableClientTab   = false;
                    oauthDownParty.EnableResourceTab = true;
                    oauthDownParty.ShowClientTab     = false;
                    oauthDownParty.ShowResourceTab   = true;

                    model.Resource = new OAuthDownResource();
                }
                else if (oauthDownParty.SubPartyType == OAuthSubPartyTypes.ClientCredentialsGrant)
                {
                    oauthDownParty.EnableClientTab   = true;
                    oauthDownParty.EnableResourceTab = false;
                    oauthDownParty.ShowClientTab     = true;
                    oauthDownParty.ShowResourceTab   = false;

                    model.Client = new OAuthDownClientViewModel();

                    model.Client.DefaultResourceScope = false;

                    model.Client.RequirePkce = false;
                    model.Client.Secrets     = new List <string> {
                        SecretGenerator.GenerateNewSecret()
                    };

                    model.Client.ResponseTypes.Add("token");
                }
                else
                {
                    throw new NotSupportedException("OAuthSubPartyTypes not supported.");
                }
            }
        }
Ejemplo n.º 2
0
        private void OidcDownPartyViewModelAfterInit(GeneralOidcDownPartyViewModel oidcDownParty, OidcDownPartyViewModel model)
        {
            if (oidcDownParty.CreateMode)
            {
                model.Client   = oidcDownParty.EnableClientTab ? new OidcDownClientViewModel() : null;
                model.Resource = oidcDownParty.EnableResourceTab ? new OAuthDownResource() : null;

                if (model.Client != null)
                {
                    model.Client.ResponseTypes.Add("code");

                    model.Client.Secrets = new List <string> {
                        SecretGenerator.GenerateNewSecret()
                    };

                    model.Client.ScopesViewModel.Add(new OidcDownScopeViewModel {
                        Scope = IdentityConstants.DefaultOidcScopes.OfflineAccess
                    });
                    model.Client.ScopesViewModel.Add(new OidcDownScopeViewModel
                    {
                        Scope           = IdentityConstants.DefaultOidcScopes.Profile,
                        VoluntaryClaims = new List <OidcDownClaim>
                        {
                            new OidcDownClaim {
                                Claim = JwtClaimTypes.Name, InIdToken = true
                            }, new OidcDownClaim {
                                Claim = JwtClaimTypes.GivenName, InIdToken = true
                            }, new OidcDownClaim {
                                Claim = JwtClaimTypes.MiddleName, InIdToken = true
                            }, new OidcDownClaim {
                                Claim = JwtClaimTypes.FamilyName, InIdToken = true
                            },
                            new OidcDownClaim {
                                Claim = JwtClaimTypes.Nickname, InIdToken = false
                            }, new OidcDownClaim {
                                Claim = JwtClaimTypes.PreferredUsername, InIdToken = false
                            },
                            new OidcDownClaim {
                                Claim = JwtClaimTypes.Birthdate, InIdToken = false
                            }, new OidcDownClaim {
                                Claim = JwtClaimTypes.Gender, InIdToken = false
                            }, new OidcDownClaim {
                                Claim = JwtClaimTypes.Picture, InIdToken = false
                            }, new OidcDownClaim {
                                Claim = JwtClaimTypes.Profile, InIdToken = false
                            },
                            new OidcDownClaim {
                                Claim = JwtClaimTypes.Website, InIdToken = false
                            }, new OidcDownClaim {
                                Claim = JwtClaimTypes.Locale, InIdToken = true
                            }, new OidcDownClaim {
                                Claim = JwtClaimTypes.Zoneinfo, InIdToken = false
                            }, new OidcDownClaim {
                                Claim = JwtClaimTypes.UpdatedAt, InIdToken = false
                            }
                        }
                    });
                    model.Client.ScopesViewModel.Add(new OidcDownScopeViewModel {
                        Scope = JwtClaimTypes.Email, VoluntaryClaims = new List <OidcDownClaim> {
                            new OidcDownClaim {
                                Claim = JwtClaimTypes.Email, InIdToken = true
                            }, new OidcDownClaim {
                                Claim = JwtClaimTypes.EmailVerified, InIdToken = false
                            }
                        }
                    });
                    model.Client.ScopesViewModel.Add(new OidcDownScopeViewModel {
                        Scope = JwtClaimTypes.Address, VoluntaryClaims = new List <OidcDownClaim> {
                            new OidcDownClaim {
                                Claim = JwtClaimTypes.Address, InIdToken = true
                            }
                        }
                    });
                    model.Client.ScopesViewModel.Add(new OidcDownScopeViewModel {
                        Scope = JwtClaimTypes.PhoneNumber, VoluntaryClaims = new List <OidcDownClaim> {
                            new OidcDownClaim {
                                Claim = JwtClaimTypes.PhoneNumber, InIdToken = true
                            }, new OidcDownClaim {
                                Claim = JwtClaimTypes.PhoneNumberVerified, InIdToken = false
                            }
                        }
                    });
                }
            }
        }