NewQueryState implements the sql.AuthorizationHandler interface.
(ctx *sql.Context)
| 64 | |
| 65 | // NewQueryState implements the sql.AuthorizationHandler interface. |
| 66 | func (h *AuthorizationHandler) NewQueryState(ctx *sql.Context) sql.AuthorizationQueryState { |
| 67 | state := AuthorizationQueryState{} |
| 68 | LockRead(func() { |
| 69 | state.role = GetRole(ctx.Client().User) |
| 70 | if !state.role.IsValid() { |
| 71 | state.err = errors.Errorf(`role "%s" does not exist`, state.role.Name) |
| 72 | return |
| 73 | } |
| 74 | state.public = GetRole("public") |
| 75 | if !state.public.IsValid() { |
| 76 | state.err = errors.Errorf(`role "%s" does not exist`, state.public.Name) |
| 77 | return |
| 78 | } |
| 79 | }) |
| 80 | return state |
| 81 | } |
| 82 | |
| 83 | // HandleAuth implements the sql.AuthorizationHandler interface. |
| 84 | func (h *AuthorizationHandler) HandleAuth(ctx *sql.Context, aqs sql.AuthorizationQueryState, auth vitess.AuthInformation) error { |
no test coverage detected