예제 #1
0
        internal virtual async Task <BaseContext> Connect()
        {
            try
            {
                if (string.IsNullOrEmpty(ConnectionSettings.Token))
                {
                    Client = new KeycloakClient(
                        ConnectionSettings.Url,
                        ConnectionSettings.Username,
                        ConnectionSettings.Password);
                }
                else
                {
                    Client = new KeycloakClient(
                        ConnectionSettings.Url,
                        () => { return(ConnectionSettings.Token); });
                }
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }

            return(this);
        }
예제 #2
0
 private void InitialiseKeycloak()
 {
     KeycloakClient.Init(_configuration.KeycloakBaseUrl,
                         _configuration.KeycloakRealm,
                         _configuration.KeycloakUserName,
                         _configuration.KeycloakPassword,
                         _configuration.KeycloakClientId);
 }
예제 #3
0
 protected IntegrationTestBase()
 {
     client = new KeycloakClient(new KeycloakAdminClientOptions
     {
         ClientId = "admin-cli",
         Username = "******",
         Password = "******",
         Realm    = "master",
         Url      = new Uri("http://localhost:8080/auth/")
     });
 }
예제 #4
0
 public CheckPathConventions()
 {
     client = new KeycloakClient(new KeycloakAdminClientOptions
     {
         ClientId    = "admin-cli",
         Username    = "******",
         Password    = "******",
         ClientScope = "testClientScope",
         Realm       = "testRealm",
         Url         = new Uri("http://localhost:8080/auth/")
     });
 }
예제 #5
0
        public KeycloakClientShould()
        {
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                                .Build();

            string url      = configuration["url"];
            string userName = configuration["userName"];
            string password = configuration["password"];

            _client = new KeycloakClient(new UrlService(url), new UserService(userName, password));
        }
예제 #6
0
        public IdentityService(IConfiguration configuration)
        {
            var configuration1 = configuration;

            _realM        = configuration1.GetValue <string>("IdentitySettings:Realm");
            _apiUri       = configuration1.GetValue <string>("IdentitySettings:ApiUrl");
            _clientId     = configuration1.GetValue <string>("IdentitySettings:ClientId");
            _clientSecret = configuration1.GetValue <string>("IdentitySettings:ClientSecret");
            var username = configuration1.GetValue <string>("IdentitySettings:Username");
            var password = configuration1.GetValue <string>("IdentitySettings:Password");

            KeycloakClient = new KeycloakClient(_apiUri, username, password);
        }
예제 #7
0
        /// <summary>
        /// Update existing client with filled instance of KeycloakClient object and valid client guid.
        /// </summary>
        /// <param name="keycloakClient">Filled instance of KeycloakClient object.</param>
        /// <param name="clientGuid">Valid client guid.</param>
        /// <returns></returns>
        public async Task <bool> UpdateClient(KeycloakClient keycloakClient, string accessToken, string clientGuid)
        {
            using (HttpClient httpClient = new HttpClient())
            {
                using (HttpContent httpContent = new StringContent(JsonConvert.SerializeObject(keycloakClient)))
                {
                    httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
                    httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                    var response = await httpClient.PutAsync(KeycloakConstants.clientEndpoint + "/" + clientGuid, httpContent);

                    return(response.StatusCode.Equals(HttpStatusCode.NoContent));
                }
            }
        }
예제 #8
0
 public RealmSessions(IRealmContext context)
 {
     _context = context;
     _client  = context.Client;
 }
 public AdminEvents(IRealmContext context)
 {
     _context = context;
     _client  = context.Client;
 }
예제 #10
0
 public PartialExport(IRealmContext context)
 {
     _context = context;
     _client  = context.Client;
 }
예제 #11
0
 public Client(IRealmContext context)
 {
     _context = context;
     _client  = context.Client;
 }
 //TODO: Context has to be modify
 public Realm(BaseContext context)
 {
     _context = context;
     _client  = _context.Client;
 }
 public Users(IRealmContext context)
 {
     _context = context;
     _client  = _context.Client;
 }
 public DefaultGroups(IRealmContext context)
 {
     _context = context;
     _client  = context.Client;
 }
예제 #15
0
 public KeycloakFacade()
 {
     mKeycloakClient = new KeycloakClient("http://localhost:8080/", "admin", "admin");
 }
 public Revocation(IRealmContext context)
 {
     _context = context;
     _client  = context.Client;
 }