diff --git a/VERAG_REST_SERVER/App_Start/AddAuthTokenHeaderParamete.vb b/VERAG_REST_SERVER/App_Start/AddAuthTokenHeaderParamete.vb index 10c0554..9cc5cfc 100644 --- a/VERAG_REST_SERVER/App_Start/AddAuthTokenHeaderParamete.vb +++ b/VERAG_REST_SERVER/App_Start/AddAuthTokenHeaderParamete.vb @@ -22,9 +22,20 @@ ' .in = "header", ' .description = "access token", ' .required = True, -' .type = "string" +' .type = "string", +' .[default] = "Bearer " ' }) ' End If ' End Sub + + + + + 'End Class + + + + + diff --git a/VERAG_REST_SERVER/App_Start/SwaggerConfig.vb b/VERAG_REST_SERVER/App_Start/SwaggerConfig.vb index ab6333b..9a6a33f 100644 --- a/VERAG_REST_SERVER/App_Start/SwaggerConfig.vb +++ b/VERAG_REST_SERVER/App_Start/SwaggerConfig.vb @@ -35,8 +35,12 @@ Public Class SwaggerConfig ' scopes.Add("read", "Read access to protected resources") ' scopes.Add("write", "Write access to protected resources") ' End Function) - c.BasicAuth("basic").Description("Basic HTTP Authentication") + 'c.BasicAuth("basic").Description("Basic HTTP Authentication") + + 'c.ApiKey("apiKey").Description("API Key Authentication").Name("apiKey").In("header") + c.OperationFilter(Of AddAuthorizationHeaderParameterOperationFilter)() + 'c.OperationFilter(Of AddAuthTokenHeaderParameter)() 'c.IncludeXmlComments($"{AppDomain.CurrentDomain.BaseDirectory}\bin\MyApi.XML") @@ -46,6 +50,7 @@ Public Class SwaggerConfig c.DocumentTitle(descr) c.EnableDiscoveryUrlSelector() c.DocExpansion(DocExpansion.Full) + c.EnableApiKeySupport("apiKey", "header") 'c.EnableOAuth2Support(clientId:="test-client-id", clientSecret:=Nothing, realm:="test-realm", appName:="Swagger UI", additionalQueryStringParams:=New Dictionary(Of String, String)() From { ' {"foo", "bar"} diff --git a/VERAG_REST_SERVER/App_Start/WebApiConfig.vb b/VERAG_REST_SERVER/App_Start/WebApiConfig.vb index 9a4bfae..269a958 100644 --- a/VERAG_REST_SERVER/App_Start/WebApiConfig.vb +++ b/VERAG_REST_SERVER/App_Start/WebApiConfig.vb @@ -59,7 +59,7 @@ Public Module WebApiConfig Dim constraintsResolver = New DefaultInlineConstraintResolver() constraintsResolver.ConstraintMap.Add("apiVersion", GetType(ApiVersionRouteConstraint)) config.MapHttpAttributeRoutes(constraintsResolver) - 'config.Filters.Add(New AuthorizeAttribute) + config.Filters.Add(New AuthorizeAttribute) 'wenn alle API Aufrufe autorisiert werden müssen! config.AddApiVersioning(Function(options)