NewStatic returns a new StaticInterceptor from a static authorization policy JSON string.
(authzPolicy string)
| 44 | // NewStatic returns a new StaticInterceptor from a static authorization policy |
| 45 | // JSON string. |
| 46 | func NewStatic(authzPolicy string) (*StaticInterceptor, error) { |
| 47 | rbacs, policyName, err := translatePolicy(authzPolicy) |
| 48 | if err != nil { |
| 49 | return nil, err |
| 50 | } |
| 51 | chainEngine, err := rbac.NewChainEngine(rbacs, policyName) |
| 52 | if err != nil { |
| 53 | return nil, err |
| 54 | } |
| 55 | return &StaticInterceptor{*chainEngine}, nil |
| 56 | } |
| 57 | |
| 58 | // UnaryInterceptor intercepts incoming Unary RPC requests. |
| 59 | // Only authorized requests are allowed to pass. Otherwise, an unauthorized |