public GraphQLUrlGenerator(IOptions <MyUrlsOptions> urlsOptions, IAssetStore assetStore, bool allowAssetSourceUrl) { this.assetStore = assetStore; this.urlsOptions = urlsOptions.Value; CanGenerateAssetSourceUrl = allowAssetSourceUrl; }
private static IEnumerable <Client> CreateStaticClients(MyUrlsOptions urlsOptions) { var id = Constants.FrontendClient; yield return(new Client { ClientId = id, ClientName = id, RedirectUris = new List <string> { urlsOptions.BuildUrl("login;"), urlsOptions.BuildUrl("identity-server/client-callback-silent/"), urlsOptions.BuildUrl("identity-server/client-callback-popup/") }, PostLogoutRedirectUris = new List <string> { urlsOptions.BuildUrl("logout", false) }, AllowAccessTokensViaBrowser = true, AllowedGrantTypes = GrantTypes.Implicit, AllowedScopes = new List <string> { IdentityServerConstants.StandardScopes.OpenId, IdentityServerConstants.StandardScopes.Profile, Constants.ApiScope, Constants.ProfileScope, Constants.RoleScope }, RequireConsent = false }); }
public static SwaggerSecurityScheme CreateOAuthSchema(MyUrlsOptions urlOptions) { var tokenUrl = urlOptions.BuildUrl($"{Constants.IdentityServerPrefix}/connect/token", false); var securityDocs = LoadDocs("security"); var securityText = securityDocs.Replace("<TOKEN_URL>", tokenUrl); var result = new SwaggerSecurityScheme { TokenUrl = tokenUrl, Type = SwaggerSecuritySchemeType.OAuth2, Flow = SwaggerOAuth2Flow.Application, Scopes = new Dictionary <string, string> { { Constants.ApiScope, "Read and write access to the API" }, { SquidexRoles.AppOwner, "App contributor with Owner permission." }, { SquidexRoles.AppEditor, "Client (writer) or App contributor with Editor permission." }, { SquidexRoles.AppReader, "Client (readonly) or App contributor with Editor permission." }, { SquidexRoles.AppDeveloper, "App contributor with Developer permission." } }, Description = securityText }; return(result); }
public static SwaggerSecurityScheme CreateOAuthSchema(MyUrlsOptions urlOptions) { var tokenUrl = urlOptions.BuildUrl($"{Constants.IdentityPrefix}/connect/token"); var securityDocs = LoadDocs("security"); var securityDescription = securityDocs.Replace("<TOKEN_URL>", tokenUrl); var result = new SwaggerSecurityScheme { TokenUrl = tokenUrl, Type = SwaggerSecuritySchemeType.OAuth2, Flow = SwaggerOAuth2Flow.Application, Scopes = new Dictionary <string, string> { { Constants.ApiScope, "Read and write access to the API" }, { SquidexRoles.AppOwner, "You get this scope / role when you are owner of the app you are accessing." }, { SquidexRoles.AppEditor, "You get this scope / role when you are owner of the app you are accessing or when the subject is a client." }, { SquidexRoles.AppDeveloper, "You get this scope / role when you are owner of the app you are accessing." } }, Description = securityDescription }; return(result); }
private static IEnumerable <Client> CreateStaticClients(MyUrlsOptions urlsOptions) { var frontendId = Constants.FrontendClient; yield return(new Client { ClientId = frontendId, ClientName = frontendId, RedirectUris = new List <string> { urlsOptions.BuildUrl("login;"), urlsOptions.BuildUrl("client-callback-silent", false), urlsOptions.BuildUrl("client-callback-popup", false) }, PostLogoutRedirectUris = new List <string> { urlsOptions.BuildUrl("logout", false) }, AllowAccessTokensViaBrowser = true, AllowedGrantTypes = GrantTypes.Implicit, AllowedScopes = new List <string> { IdentityServerConstants.StandardScopes.OpenId, IdentityServerConstants.StandardScopes.Profile, IdentityServerConstants.StandardScopes.Email, Constants.ApiScope, Constants.ProfileScope, Constants.RoleScope }, RequireConsent = false }); var internalClient = Constants.InternalClientId; yield return(new Client { ClientId = internalClient, ClientName = internalClient, ClientSecrets = new List <Secret> { new Secret(Constants.InternalClientSecret) }, RedirectUris = new List <string> { urlsOptions.BuildUrl($"{Constants.PortalPrefix}/signin-oidc", false), urlsOptions.BuildUrl($"{Constants.OrleansPrefix}/signin-oidc", false) }, AccessTokenLifetime = (int)TimeSpan.FromDays(30).TotalSeconds, AllowedGrantTypes = GrantTypes.ImplicitAndClientCredentials, AllowedScopes = new List <string> { IdentityServerConstants.StandardScopes.OpenId, IdentityServerConstants.StandardScopes.Profile, IdentityServerConstants.StandardScopes.Email, Constants.ApiScope, Constants.ProfileScope, Constants.RoleScope }, RequireConsent = false }); }
public static SwaggerDocument CreateApiDocument(HttpContext context, MyUrlsOptions urlOptions, string appName) { var scheme = string.Equals(context.Request.Scheme, "http", StringComparison.OrdinalIgnoreCase) ? SwaggerSchema.Http : SwaggerSchema.Https; var document = new SwaggerDocument { Schemes = new List <SwaggerSchema> { scheme }, Consumes = new List <string> { "application/json" }, Produces = new List <string> { "application/json" }, Info = new SwaggerInfo { Title = $"Squidex API for {appName} App" }, BasePath = Constants.ApiPrefix }; if (!string.IsNullOrWhiteSpace(context.Request.Host.Value)) { document.Host = context.Request.Host.Value; } return(document); }
public SchemasSwaggerGenerator(IOptions <MyUrlsOptions> urlOptions, IEnumerable <IDocumentProcessor> documentProcessors) { this.urlOptions = urlOptions.Value; settings.ConfigureSchemaSettings(); foreach (var processor in documentProcessors) { settings.DocumentProcessors.Add(processor); } }
public SchemasSwaggerGenerator(IHttpContextAccessor context, SwaggerOwinSettings swaggerSettings, IOptions <MyUrlsOptions> urlOptions) { this.context = context.HttpContext; this.urlOptions = urlOptions.Value; schemaGenerator = new SwaggerJsonSchemaGenerator(swaggerSettings); schemaResolver = new SwaggerSchemaResolver(document, swaggerSettings); swaggerGenerator = new SwaggerGenerator(schemaGenerator, swaggerSettings, schemaResolver); schemaBodyDescription = SwaggerHelper.LoadDocs("schemabody"); schemaQueryDescription = SwaggerHelper.LoadDocs("schemaquery"); }
private static SwaggerSettings ConfigurePaths(this SwaggerSettings settings, MyUrlsOptions urlOptions) { settings.SwaggerRoute = $"{Constants.ApiPrefix}/swagger/v1/swagger.json"; settings.PostProcess = document => { document.BasePath = Constants.ApiPrefix; document.Info.ExtensionData = new Dictionary <string, object> { ["x-logo"] = new { url = urlOptions.BuildUrl("images/logo-white.png", false), backgroundColor = "#3f83df" } }; }; settings.MiddlewareBasePath = Constants.ApiPrefix; return(settings); }
public UsagesController( ICommandBus commandBus, IUsageTracker usageTracker, IAppLogStore appLogStore, IAppPlansProvider appPlansProvider, IAssetUsageTracker assetStatsRepository, IDataProtectionProvider dataProtection, IOptions <MyUrlsOptions> urlsOptions) : base(commandBus) { this.usageTracker = usageTracker; this.appLogStore = appLogStore; this.appPlansProvider = appPlansProvider; this.assetStatsRepository = assetStatsRepository; this.urlsOptions = urlsOptions.Value; dataProtector = dataProtection.CreateProtector("LogToken"); }
public static SwaggerDocument CreateApiDocument(HttpContext context, MyUrlsOptions urlOptions, string appName) { var scheme = string.Equals(context.Request.Scheme, "http", StringComparison.OrdinalIgnoreCase) ? SwaggerSchema.Http : SwaggerSchema.Https; var document = new SwaggerDocument { Tags = new List <SwaggerTag>(), Schemes = new List <SwaggerSchema> { scheme }, Consumes = new List <string> { "application/json" }, Produces = new List <string> { "application/json" }, Info = new SwaggerInfo { ExtensionData = new Dictionary <string, object> { ["x-logo"] = new { url = urlOptions.BuildUrl("images/logo-white.png", false), backgroundColor = "#3f83df" } }, Title = $"Squidex API for {appName} App", Version = "1.0" }, BasePath = "/api" }; if (!string.IsNullOrWhiteSpace(context.Request.Host.Value)) { document.Host = context.Request.Host.Value; } document.SecurityDefinitions.Add(Constants.SecurityDefinition, CreateOAuthSchema(urlOptions)); return(document); }
public static SwaggerSecurityScheme CreateOAuthSchema(MyUrlsOptions urlOptions) { var tokenUrl = urlOptions.BuildUrl($"{Constants.IdentityServerPrefix}/connect/token", false); var securityDocs = LoadDocs("security"); var securityText = securityDocs.Replace("<TOKEN_URL>", tokenUrl); var result = new SwaggerSecurityScheme { TokenUrl = tokenUrl, Type = SwaggerSecuritySchemeType.OAuth2, Flow = SwaggerOAuth2Flow.Application, Scopes = new Dictionary <string, string> { { Constants.ApiScope, "Read and write access to the API" } }, Description = securityText }; return(result); }
private static SwaggerSecurityScheme CreateOAuthSchema(MyUrlsOptions urlOptions) { var securityScheme = new SwaggerSecurityScheme(); var tokenUrl = urlOptions.BuildUrl($"{Constants.IdentityServerPrefix}/connect/token", false); securityScheme.TokenUrl = tokenUrl; var securityDocs = NSwagHelper.LoadDocs("security"); var securityText = securityDocs.Replace("<TOKEN_URL>", tokenUrl); securityScheme.Description = securityText; securityScheme.Type = SwaggerSecuritySchemeType.OAuth2; securityScheme.Flow = SwaggerOAuth2Flow.Application; securityScheme.Scopes = new Dictionary <string, string> { [Constants.ApiScope] = "Read and write access to the API" }; return(securityScheme); }
public SchemasSwaggerGenerator(IHttpContextAccessor context, SwaggerSettings settings, IOptions<MyUrlsOptions> urlOptions) { this.context = context.HttpContext; this.settings = settings; this.urlOptions = urlOptions.Value; }
private static SwaggerSettings ConfigureIdentity(this SwaggerSettings settings, MyUrlsOptions urlOptions) { settings.DocumentProcessors.Add(new SecurityDefinitionAppender(Constants.SecurityDefinition, SwaggerHelper.CreateOAuthSchema(urlOptions))); settings.OperationProcessors.Add(new ScopesProcessor()); return(settings); }
public static SwaggerSettings <T> ConfigureIdentity <T>(this SwaggerSettings <T> settings, MyUrlsOptions urlOptions) where T : SwaggerGeneratorSettings, new() { settings.GeneratorSettings.DocumentProcessors.Add( new SecurityDefinitionAppender( Constants.SecurityDefinition, SwaggerHelper.CreateOAuthSchema(urlOptions))); settings.GeneratorSettings.OperationProcessors.Add(new ScopesProcessor()); return(settings); }