-
Notifications
You must be signed in to change notification settings - Fork 18.5k
feat: add new table of end user oauth #28351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/end-user-oauth
Are you sure you want to change the base?
Changes from 1 commit
c493e08
adf673d
76069b5
5e93a61
39de9e7
6cd7ab4
153609b
bbd466e
8f6937e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,6 +114,58 @@ def credentials(self) -> dict[str, Any]: | |
| return cast(dict[str, Any], json.loads(self.encrypted_credentials)) | ||
|
|
||
|
|
||
| class EndUserAuthenticationProvider(TypeBase): | ||
| """ | ||
| This table stores the authentication credentials for end users in tools. | ||
| Mimics the BuiltinToolProvider structure but for end users instead of tenants. | ||
| """ | ||
|
|
||
| __tablename__ = "tool_enduser_authentication_providers" | ||
| __table_args__ = ( | ||
| sa.PrimaryKeyConstraint("id", name="tool_enduser_authentication_provider_pkey"), | ||
| sa.UniqueConstraint("tenant_id", "provider", "end_user_id", "name", name="unique_enduser_authentication_provider"), | ||
asukaminato0721 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| sa.Index("tool_enduser_authentication_provider_tenant_id_idx", "tenant_id"), | ||
QuantumGhost marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| sa.Index("tool_enduser_authentication_provider_end_user_id_idx", "end_user_id"), | ||
| ) | ||
|
|
||
| # id of the authentication provider | ||
| id: Mapped[str] = mapped_column(StringUUID, server_default=sa.text("uuid_generate_v4()"), init=False) | ||
asukaminato0721 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| name: Mapped[str] = mapped_column( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, enforcing name uniqueness for a Ideally, we should rely on IDs as the primary identifier and treat names merely as user-facing hints. Therefore, strict uniqueness shouldn't be required. If a user creates duplicate names, they should bear the responsibility for any ambiguity. Enforcing name uniqueness has caused implementation issues in the past, such as with credential management in the EE version. Furthermore, it complicates name generation. That said, I suggest discussing this with the PM. I’ve skimmed the PRD and found no explicit requirement for name uniqueness.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, should we remove the unique constraint at all? Since ID is enough for uniqueness |
||
| String(256), | ||
| nullable=False, | ||
| server_default=sa.text("'API KEY 1'::character varying"), | ||
| ) | ||
CourTeous33 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # id of the tenant | ||
| tenant_id: Mapped[str] = mapped_column(StringUUID, nullable=False) | ||
| # id of the end user | ||
| end_user_id: Mapped[str] = mapped_column(StringUUID, nullable=False) | ||
| # name of the tool provider | ||
| provider: Mapped[str] = mapped_column(String(256), nullable=False) | ||
asukaminato0721 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # encrypted credentials for the end user | ||
| encrypted_credentials: Mapped[str | None] = mapped_column(sa.Text, nullable=True, default=None) | ||
asukaminato0721 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| created_at: Mapped[datetime] = mapped_column( | ||
| sa.DateTime, nullable=False, server_default=sa.text("CURRENT_TIMESTAMP(0)"), init=False | ||
| ) | ||
| updated_at: Mapped[datetime] = mapped_column( | ||
| sa.DateTime, | ||
| nullable=False, | ||
| server_default=sa.text("CURRENT_TIMESTAMP(0)"), | ||
| onupdate=func.current_timestamp(), | ||
| init=False, | ||
| ) | ||
asukaminato0721 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # credential type, e.g., "api-key", "oauth2" | ||
| credential_type: Mapped[str] = mapped_column( | ||
asukaminato0721 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| String(32), nullable=False, server_default=sa.text("'api-key'::character varying"), default="api-key" | ||
| ) | ||
CourTeous33 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| expires_at: Mapped[int] = mapped_column(sa.BigInteger, nullable=False, server_default=sa.text("-1"), default=-1) | ||
|
|
||
| @property | ||
| def credentials(self) -> dict[str, Any]: | ||
| if not self.encrypted_credentials: | ||
| return {} | ||
| return cast(dict[str, Any], json.loads(self.encrypted_credentials)) | ||
|
|
||
|
|
||
| class ApiToolProvider(TypeBase): | ||
| """ | ||
| The table stores the api providers. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.