zitadel/internal/protoc/protoc-gen-authoption/templates/auth_method_mapping.go.tmpl
2020-03-25 10:54:45 +01:00

35 lines
1013 B
Cheetah

// Code generated by protoc-gen-authmethod. DO NOT EDIT.
package {{.File.GoPkg.Name}}
import (
"google.golang.org/grpc"
utils_auth "github.com/caos/zitadel/internal/api/auth"
"github.com/caos/zitadel/internal/api/grpc/server/middleware"
)
{{ range $s := .File.Services }}
/**
* {{$s.Name}}
*/
var {{$s.Name}}_AuthMethods = utils_auth.MethodMapping {
{{ range $m := $s.Method}}
{{ $mAuthOpt := option $m.Options "caos.zitadel.utils.v1.auth_option" }}
{{ if and $mAuthOpt $mAuthOpt.Permission }}
"/{{$.File.Package}}.{{$s.Name}}/{{.Name}}": utils_auth.Option{
Permission: "{{$mAuthOpt.Permission}}",
CheckParam: "{{$mAuthOpt.CheckFieldName}}",
},
{{end}}
{{ end}}
}
func {{$s.Name}}_Authorization_Interceptor(verifier utils_auth.TokenVerifier, authConf *utils_auth.Config) grpc.UnaryServerInterceptor {
return middleware.AuthorizationInterceptor(verifier, authConf, {{$s.Name}}_AuthMethods)
}
{{ end }}