Skip to content

Commit

Permalink
fix(openapi): make authTypes public
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightapes committed May 22, 2023
1 parent 9abbd90 commit 966e9c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/openapi/chi.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (a *API) ChiAuthMiddleware(isAllowed func(authName string, scopes []string,
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
authTypes := config[rctx.RouteMethod].authTypes
authTypes := config[rctx.RouteMethod].AuthTypes
for name, scopes := range authTypes {
if isAllowed(name, scopes, r) {
isAuthenticated = true
Expand Down
6 changes: 3 additions & 3 deletions pkg/openapi/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type HandlerConfig struct {
Method string
Path string
HandlerFunc http.HandlerFunc
authTypes map[string][]string
AuthTypes map[string][]string
}

type API struct {
Expand Down Expand Up @@ -240,7 +240,7 @@ func (a *API) toPath(desc PathDesc, pathBuilder *PathBuilder) (*Operation, *Hand
handlerConfig := &HandlerConfig{
Path: pathBuilder.path,
HandlerFunc: desc.GetHandlerFunc(),
authTypes: map[string][]string{},
AuthTypes: map[string][]string{},
}

for s := range a.OpenAPI.Components.SecuritySchemes {
Expand All @@ -252,7 +252,7 @@ func (a *API) toPath(desc PathDesc, pathBuilder *PathBuilder) (*Operation, *Hand
s: scopes,
}
ops.Security = append(ops.Security, sec)
handlerConfig.authTypes[s] = scopes
handlerConfig.AuthTypes[s] = scopes
}
}

Expand Down

0 comments on commit 966e9c9

Please sign in to comment.