Skip to content

Commit da67ba1

Browse files
authored
Fixing ServeMuxVisitor scopes (#61)
1 parent 9ba9bdb commit da67ba1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/go/servemux_visitor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
} from "../utils/mod.ts";
1616
import { getMethods, getPath, hasBody, ScopesDirective } from "../rest/mod.ts";
1717
import { StructVisitor } from "./struct_visitor.ts";
18-
import { expandType, fieldName, methodName } from "./helpers.ts";
18+
import { expandType, fieldName, methodName, strQuote } from "./helpers.ts";
1919
import { translateAlias } from "./alias_visitor.ts";
2020
import { getImporter, GoVisitor } from "./go_visitor.ts";
2121
import { IMPORTS } from "./constant.ts";
@@ -72,7 +72,9 @@ class ServeMuxServiceVisitor extends GoVisitor {
7272

7373
if (scopes.length > 0) {
7474
this.write(
75-
`if err := ${$.authorization}.CheckScopes(r.Context(), "write:clusters"); err != nil {
75+
`if err := ${$.authorization}.CheckScopes(r.Context(), ${
76+
scopes.map((v) => strQuote(v)).join(", ")
77+
}); err != nil {
7678
${$.thttp}.Error(w, nil, err, ${$.errorz}.PermissionDenied)
7779
return
7880
}\n`,

0 commit comments

Comments
 (0)