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); }
private void InitialiseKeycloak() { KeycloakClient.Init(_configuration.KeycloakBaseUrl, _configuration.KeycloakRealm, _configuration.KeycloakUserName, _configuration.KeycloakPassword, _configuration.KeycloakClientId); }
protected IntegrationTestBase() { client = new KeycloakClient(new KeycloakAdminClientOptions { ClientId = "admin-cli", Username = "******", Password = "******", Realm = "master", Url = new Uri("http://localhost:8080/auth/") }); }
public CheckPathConventions() { client = new KeycloakClient(new KeycloakAdminClientOptions { ClientId = "admin-cli", Username = "******", Password = "******", ClientScope = "testClientScope", Realm = "testRealm", Url = new Uri("http://localhost:8080/auth/") }); }
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)); }
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); }
/// <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)); } } }
public RealmSessions(IRealmContext context) { _context = context; _client = context.Client; }
public AdminEvents(IRealmContext context) { _context = context; _client = context.Client; }
public PartialExport(IRealmContext context) { _context = context; _client = context.Client; }
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; }
public KeycloakFacade() { mKeycloakClient = new KeycloakClient("http://localhost:8080/", "admin", "admin"); }
public Revocation(IRealmContext context) { _context = context; _client = context.Client; }