// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services .AddTokenAuthentication(Configuration) .AddAuthorization() .AddControllers() .AddJsonOptions(o => { o.JsonSerializerOptions.WriteIndented = true; }); services.AddRouting(r => r.LowercaseUrls = true); #if DEBUG // Register the Swagger generator, defining 1 or more Swagger documents // https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-3.1&tabs=visual-studio services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "CertifyServer - Certificate Server API", Version = "v1", Description = "CertifyServer provides a certificate services API for use in devops, CI/CD, middleware etc. Certificates are managed by Certify The Web on the primary server using ACME, with API access controlled using API tokens." }); // declare authorization method c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", Name = "Authorization", Scheme = "bearer", BearerFormat = "JWT", In = ParameterLocation.Header, Type = SecuritySchemeType.Http }); // set security requirement c.AddSecurityRequirement(new OpenApiSecurityRequirement { { new OpenApiSecurityScheme { Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } }, new List <string>() } }); }); #endif // connect to certify service var configManager = new ServiceConfigManager(); var defaultConnectionConfig = new Shared.ServerConnection(configManager.GetServiceConfig()); var connections = ServerConnectionManager.GetServerConnections(null, defaultConnectionConfig); var serverConnection = connections.FirstOrDefault(c => c.IsDefault = true); services.AddSingleton(typeof(Certify.Client.ICertifyInternalApiClient), new Client.CertifyApiClient(configManager, serverConnection)); }
public ServiceGatewayManager() { _serviceGatewayCache = new Dictionary <string, ServiceGateway>(); var serviceConfigManager = new ServiceConfigManager(); _serviceGateway = new ServiceGateway(serviceConfigManager); }
private void AddServiceGatewayForServer(ServiceGateway service, AuthTokenDto authToken) { try { _serverInfo = service.Server.GetServerInfo(authToken.ServerDto, authToken.Token); } catch (Exception exc) { // default the configuration to vsphere _serverInfo = new ServerInfoDto { Release = "Vsphere", ProductName = "idm" }; } if (authToken.ServerDto.ServerName == "10.161.26.243") { _serverInfo.Release = "Lightwave"; } var serviceConfigManager = new ServiceConfigManager(_serverInfo.Release); var serviceGateway = new ServiceGateway(serviceConfigManager); SnapInContext.Instance.ServiceGatewayManager.Add(authToken.ServerDto.ServerName, serviceGateway); }
private void HandleMessage(ClientConfigurationMessage message, ServiceConfig config) { Log.Information( $"Message size updated from {config.MessageMaxSizeBytes} " + $"to {message.MaxClientMessageSizeBytes}"); config.MessageMaxSizeBytes = message.MaxClientMessageSizeBytes; ServiceConfigManager.UpdateConfigSource( c => c.MessageMaxSizeBytes, config.MessageMaxSizeBytes); }
public static void Start() { var config = ServiceConfigManager.GetConfig(); var provider = ConfigureServices(config); RegisterExternalConfiguration(provider, config); var resourceMonitor = provider.GetService <IResourceMonitor>(); resourceMonitor.StartMonitoring(ServiceConfigManager.GetScanFoldersConfig(config)); var availabilityCheck = provider.GetService <IAvailabilityCheck>(); availabilityCheck.StartChecks(); }
public BaseInstaller() { Assembly assembly = Assembly.GetCallingAssembly(); Configuration config = ConfigurationManager.OpenExeConfiguration(assembly.Location); ServiceConfigManager.LoadConfiguration(config); Installers.Add(new ServiceProcessInstaller() { Account = ServiceAccount.LocalSystem }); Installers.Add(new ServiceInstaller() { StartType = ServiceStartMode.Automatic, ServiceName = ServiceConfigManager.ServiceName, DisplayName = ServiceConfigManager.ServiceDisplayName, Description = ServiceConfigManager.ServiceDescription }); }
public UserDto UpdatePassword(ServerDto serverDto, string tenantName, UserDto user, PasswordResetRequestDto requestDto, Token token) { var upn = Uri.EscapeDataString(user.Name + "@" + user.Domain); tenantName = Uri.EscapeDataString(tenantName); var json = JsonConvert.Serialize(requestDto); var url = ServiceConfigManager.UpdatePasswordUrl(serverDto, tenantName, upn); ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; var requestConfig = new RequestSettings { Method = HttpMethod.Put, }; var headers = ServiceHelper.AddHeaders(ServiceConfigManager.JsonContentType); json = "access_token=" + token.AccessToken + "&token_type=" + token.TokenType.ToString().ToLower() + "&" + json; var result = _webRequestManager.GetResponse(url, requestConfig, headers, null, json); return(JsonConvert.Deserialize <UserDto>(result)); }