mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 06:54:28 +00:00
feat(mcp): add OAuth 2.1 support (#505)
* feat(mcp): add OAuth 2.1 support with dynamic client registration * feat(api): alias bare oauth-authorization-server discovery endpoint * fix(auth): preserve user session on OAuth sign-in redirect to consent
This commit is contained in:
@@ -249,6 +249,10 @@ model User {
|
||||
kanbanTaskComments KanbanTaskComment[]
|
||||
kanbanTaskEvents KanbanTaskEvent[]
|
||||
recentFiles RecentFileItem[]
|
||||
oauthClients OauthClient[]
|
||||
oauthRefreshTokens OauthRefreshToken[]
|
||||
oauthAccessTokens OauthAccessToken[]
|
||||
oauthConsents OauthConsent[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
@@ -264,6 +268,9 @@ model Session {
|
||||
userId String @map("user_id")
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
oauthRefreshTokens OauthRefreshToken[]
|
||||
oauthAccessTokens OauthAccessToken[]
|
||||
|
||||
@@map("sessions")
|
||||
}
|
||||
|
||||
@@ -1344,5 +1351,178 @@ model RecentFileItem {
|
||||
@@map("recent_file_items")
|
||||
}
|
||||
|
||||
model Jwks {
|
||||
id String @id @default(ulid())
|
||||
publicKey String @map("public_key")
|
||||
privateKey String @map("private_key")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
expiresAt DateTime? @map("expires_at")
|
||||
alg String?
|
||||
crv String?
|
||||
|
||||
@@map("jwks")
|
||||
}
|
||||
|
||||
model OauthClient {
|
||||
id String @id @default(ulid())
|
||||
clientId String @unique @map("client_id")
|
||||
clientSecret String? @map("client_secret")
|
||||
clientDiscoveryId String? @map("client_discovery_id")
|
||||
disabled Boolean? @default(false)
|
||||
skipConsent Boolean? @map("skip_consent")
|
||||
enableEndSession Boolean? @map("enable_end_session")
|
||||
subjectType String? @map("subject_type")
|
||||
scopes String[] @default([])
|
||||
clientCredentialsScopes String[] @default([]) @map("client_credentials_scopes")
|
||||
userId String? @map("user_id")
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime? @default(now()) @map("created_at")
|
||||
updatedAt DateTime? @updatedAt @map("updated_at")
|
||||
name String?
|
||||
uri String?
|
||||
icon String?
|
||||
contacts String[] @default([])
|
||||
tos String?
|
||||
policy String?
|
||||
softwareId String? @map("software_id")
|
||||
softwareVersion String? @map("software_version")
|
||||
softwareStatement String? @map("software_statement")
|
||||
redirectUris String[] @default([]) @map("redirect_uris")
|
||||
postLogoutRedirectUris String[] @default([]) @map("post_logout_redirect_uris")
|
||||
backchannelLogoutUri String? @map("backchannel_logout_uri")
|
||||
backchannelLogoutSessionRequired Boolean? @map("backchannel_logout_session_required")
|
||||
tokenEndpointAuthMethod String? @map("token_endpoint_auth_method")
|
||||
applicationType String? @map("application_type")
|
||||
jwks String?
|
||||
jwksUri String? @map("jwks_uri")
|
||||
grantTypes String[] @default([]) @map("grant_types")
|
||||
responseTypes String[] @default([]) @map("response_types")
|
||||
requirePKCE Boolean? @map("require_pkce")
|
||||
dpopBoundAccessTokens Boolean? @default(false) @map("dpop_bound_access_tokens")
|
||||
referenceId String? @map("reference_id")
|
||||
/// [OauthMetadata]
|
||||
metadata Json?
|
||||
|
||||
clientResources OauthClientResource[]
|
||||
refreshTokens OauthRefreshToken[]
|
||||
accessTokens OauthAccessToken[]
|
||||
consents OauthConsent[]
|
||||
|
||||
@@map("oauth_clients")
|
||||
}
|
||||
|
||||
model OauthResource {
|
||||
id String @id @default(ulid())
|
||||
identifier String @unique
|
||||
name String
|
||||
accessTokenTtl Int? @map("access_token_ttl")
|
||||
refreshTokenTtl Int? @map("refresh_token_ttl")
|
||||
signingAlgorithm String? @map("signing_algorithm")
|
||||
signingKeyId String? @map("signing_key_id")
|
||||
allowedScopes String[] @default([]) @map("allowed_scopes")
|
||||
/// [OauthCustomClaims]
|
||||
customClaims Json? @map("custom_claims")
|
||||
dpopBoundAccessTokensRequired Boolean? @default(false) @map("dpop_bound_access_tokens_required")
|
||||
disabled Boolean? @default(false)
|
||||
createdAt DateTime? @default(now()) @map("created_at")
|
||||
updatedAt DateTime? @updatedAt @map("updated_at")
|
||||
policyVersion Int? @default(1) @map("policy_version")
|
||||
/// [OauthMetadata]
|
||||
metadata Json?
|
||||
|
||||
clientResources OauthClientResource[]
|
||||
|
||||
@@map("oauth_resources")
|
||||
}
|
||||
|
||||
model OauthClientResource {
|
||||
id String @id @default(ulid())
|
||||
clientId String @map("client_id")
|
||||
client OauthClient @relation(fields: [clientId], references: [clientId], onDelete: Cascade)
|
||||
resourceId String @map("resource_id")
|
||||
resource OauthResource @relation(fields: [resourceId], references: [identifier], onDelete: Cascade)
|
||||
/// [OauthMetadata]
|
||||
metadata Json?
|
||||
createdAt DateTime? @default(now()) @map("created_at")
|
||||
|
||||
@@unique([clientId, resourceId])
|
||||
@@map("oauth_client_resources")
|
||||
}
|
||||
|
||||
model OauthRefreshToken {
|
||||
id String @id @default(ulid())
|
||||
token String @unique
|
||||
clientId String @map("client_id")
|
||||
client OauthClient @relation(fields: [clientId], references: [clientId], onDelete: Cascade)
|
||||
sessionId String? @map("session_id")
|
||||
session Session? @relation(fields: [sessionId], references: [id], onDelete: SetNull)
|
||||
userId String @map("user_id")
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
referenceId String? @map("reference_id")
|
||||
authorizationCodeId String? @map("authorization_code_id")
|
||||
resources String[] @default([])
|
||||
requestedUserInfoClaims String[] @default([]) @map("requested_user_info_claims")
|
||||
expiresAt DateTime @map("expires_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
revoked DateTime?
|
||||
rotatedAt DateTime? @map("rotated_at")
|
||||
rotationReplayResponse String? @map("rotation_replay_response")
|
||||
rotationReplayExpiresAt DateTime? @map("rotation_replay_expires_at")
|
||||
authTime DateTime? @map("auth_time")
|
||||
/// [OauthConfirmation]
|
||||
confirmation Json?
|
||||
scopes String[] @default([])
|
||||
|
||||
accessTokens OauthAccessToken[]
|
||||
|
||||
@@map("oauth_refresh_tokens")
|
||||
}
|
||||
|
||||
model OauthAccessToken {
|
||||
id String @id @default(ulid())
|
||||
token String @unique
|
||||
clientId String @map("client_id")
|
||||
client OauthClient @relation(fields: [clientId], references: [clientId], onDelete: Cascade)
|
||||
sessionId String? @map("session_id")
|
||||
session Session? @relation(fields: [sessionId], references: [id], onDelete: SetNull)
|
||||
userId String? @map("user_id")
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
referenceId String? @map("reference_id")
|
||||
authorizationCodeId String? @map("authorization_code_id")
|
||||
resources String[] @default([])
|
||||
requestedUserInfoClaims String[] @default([]) @map("requested_user_info_claims")
|
||||
refreshId String? @map("refresh_id")
|
||||
refreshToken OauthRefreshToken? @relation(fields: [refreshId], references: [id], onDelete: Cascade)
|
||||
expiresAt DateTime @map("expires_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
revoked DateTime?
|
||||
/// [OauthConfirmation]
|
||||
confirmation Json?
|
||||
scopes String[] @default([])
|
||||
|
||||
@@map("oauth_access_tokens")
|
||||
}
|
||||
|
||||
model OauthConsent {
|
||||
id String @id @default(ulid())
|
||||
clientId String @map("client_id")
|
||||
client OauthClient @relation(fields: [clientId], references: [clientId], onDelete: Cascade)
|
||||
userId String? @map("user_id")
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
referenceId String? @map("reference_id")
|
||||
resources String[] @default([])
|
||||
requestedUserInfoClaims String[] @default([]) @map("requested_user_info_claims")
|
||||
scopes String[] @default([])
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@map("oauth_consents")
|
||||
}
|
||||
|
||||
model OauthClientAssertion {
|
||||
id String @id @default(ulid())
|
||||
expiresAt DateTime @map("expires_at")
|
||||
|
||||
@@map("oauth_client_assertions")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user