public void StringToAllowedScopes()
 {
     foreach (var scope in ToLists(AllowedScopesString))
     {
         AllowedScopes.Add(scope);
     }
 }
Example #2
0
        public GoogleExternalAuthenticationConfiguration()
        {
            DefaultScopes = new List <string>(new [] { "openid", "email", "profile" });
            AllowedScopes = DefaultScopes.ToList();

            // TODO Production / Hide values
            var clientIdAsByteArray       = Convert.FromBase64String("NTA1MjAyNjgxNDkwLWhmMWE2ZDBoczF0dDgwcjExNW10YzhydHJvYmVrYWdpLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29t");
            var clientId                  = Encoding.UTF8.GetString(clientIdAsByteArray);
            var clientPasswordAsByteArray = Convert.FromBase64String("S0JUZjU4X09VLTU1MzdoZ1V1Q3Vtbl9h");
            var clientPassword            = Encoding.UTF8.GetString(clientPasswordAsByteArray);

            ClientId     = clientId;
            ClientSecret = clientPassword;

            var scopesAsString = string.Join(" ", DefaultScopes);

            if (string.IsNullOrEmpty(scopesAsString))
            {
                return;
            }

            var scopesToAdd = scopesAsString.Split(" ").Where(s => !string.IsNullOrEmpty(s)).ToList();

            foreach (var scope in scopesToAdd.Distinct().Where(scope => !AllowedScopes.Contains(scope)))
            {
                AllowedScopes.Add(scope);
            }
        }
Example #3
0
 public virtual void AddScope([NotNull] string scope)
 {
     AllowedScopes.Add(new ClientScope()
     {
         ClientId = Id,
         Scope    = scope
     });
 }
        public IdentityServer4.Models.Client GenerateClient()
        {
            if (AllowOfflineAccess)
            {
                AllowedScopes.Add(IdentityServerConstants.StandardScopes.OfflineAccess);
            }

            return(new IdentityServer4.Models.Client
            {
                ClientId = _clientId,
                ClientName = ClientName,
                AllowedGrantTypes = GrantTypes.ResourceOwnerPassword,
                Description = _secret,
                ClientSecrets =
                {
                    new Secret(_secret.Sha256())
                },
                AllowedScopes = AllowedScopes,
                AllowOfflineAccess = AllowOfflineAccess,
                AccessTokenLifetime = AccessTokenLifetime,
                AbsoluteRefreshTokenLifetime = AbsoluteRefreshTokenLifetime,
            });
        }
Example #5
0
 public void AddScope([NotNull] string scope)
 {
     AllowedScopes.Add(new ClientScopeDto(Id, scope));
 }
Example #6
0
 public void AddEmptyScope() => AllowedScopes.Add(new SimpleValue <string>(String.Empty));