apache / apache/kyuubi

[Umbrella] [Authz] Support authorization for persistent hive function calls

Open
#3,632 0 comments 0 reactions 0 assignees View on GitHub
kind:feature priority:major
Dominant language
Scala
Stars
2.4k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)

### Search before asking

- [X] I have searched in the [issues](https://github.com/apache/incubator-kyuubi/issues?q=is%3Aissue) and found no similar issues.

### Describe the feature

The spark sql AUTHZ in Kyuubi currently supports authorize create function command , drop function command, and refresh function command.

But the authentication for function usage is not implemented, anyone can use all permanent functions in hive. This behavior needs to be restricted.

### Motivation

_No response_

### Describe the solution

Since function expression may be optimized as constants by catalyst optimization rules, the function usage authorization should be injected before the optimization phase.

So before the optimization rules running, perform the collection of permanent function information involved in the logical plan and construct them as functionPrivilegeObjects.

I think it's necessary to create a class like RuleAuthorization and inject it as a post-hoc resolution dedicated to the authentication of function usage privileges.

### Additional context

According to the idea of [HIVE-18841](https://issues.apache.org/jira/browse/HIVE-18841), we only need to authenticate the usage of permanent functions, as it doesn't make sense to do usage authorization for temporary functions.

### Task list
> * [x] #4167
> * [ ] resolve the problem with 3.4
> * [ ] separate ut cases for different usage of functions, rather than putting them all in one case
> * [ ] check the calling of unresolved/non-existed functions and existing functions

> * [ ] Introduce RuleFunctionAuthorization for persistent function calls authorization
> * [ ] Increase test coverage For HiveFunctionPrivilegeBuilder
> * [ ] Increase test coverage For RuleFunctionAuthorization

### Are you willing to submit PR?

- [ ] Yes. I can submit a PR independently to improve.
- [X] Yes. I would be willing to submit a PR with guidance from the Kyuubi community to improve.
- [ ] No. I cannot submit a PR at this time.

Contributor guide

Open the contributing guide

Research direction

Start with the proposed RuleFunctionAuthorization entry point and the existing HiveFunctionPrivilegeBuilder tests. Review how persistent functions are collected from the logical plan before Catalyst optimization, then add coverage for authorized and unauthorized usage, including unresolved or nonexistent functions. Done means persistent function usage is checked while temporary functions remain out of scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala, spark, sql
Domain
authorization, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.