-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsys-oauth-resource.object.ts
More file actions
143 lines (124 loc) · 4 KB
/
Copy pathsys-oauth-resource.object.ts
File metadata and controls
143 lines (124 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { ObjectSchema, Field } from '@objectstack/spec/data';
/**
* sys_oauth_resource — Registered OAuth protected resource (RFC 8707)
*
* Backed by `@better-auth/oauth-provider`'s `oauthResource` model
* (better-auth ≥ 1.7). Each row registers a resource server (audience)
* that clients may request tokens for via the RFC 8707 `resource`
* parameter — e.g. the platform's own MCP endpoint. Carries the per-
* resource token policy (TTLs, signing, allowed scopes, DPoP requirement).
*
* @namespace sys
*/
export const SysOauthResource = ObjectSchema.create({
name: 'sys_oauth_resource',
label: 'OAuth Resource',
pluralLabel: 'OAuth Resources',
icon: 'server',
isSystem: true,
managedBy: 'better-auth',
// ADR-0010 §3.7 — managed by better-auth; tenants may not edit schema,
// but may add overlay row-level config. Use `no-overlay` if you need to
// forbid sys_metadata overlays entirely.
protection: {
lock: 'full',
reason: 'Identity table managed by better-auth — see ADR-0010.',
docsUrl: 'https://docs.objectstack.ai/adr/0010-metadata-protection',
},
description: 'Registered OAuth protected resources (RFC 8707 resource indicators)',
displayNameField: 'name',
nameField: 'name',
highlightFields: ['name', 'identifier', 'disabled'],
fields: {
id: Field.text({
label: 'ID',
required: true,
readonly: true,
}),
identifier: Field.text({
label: 'Identifier',
required: true,
maxLength: 1024,
description: 'Resource indicator URI presented in the RFC 8707 resource parameter',
}),
name: Field.text({
label: 'Name',
required: true,
maxLength: 255,
}),
access_token_ttl: Field.number({
label: 'Access Token TTL',
required: false,
description: 'Access-token lifetime in seconds for this resource (overrides the server default)',
}),
refresh_token_ttl: Field.number({
label: 'Refresh Token TTL',
required: false,
description: 'Refresh-token lifetime in seconds for this resource (overrides the server default)',
}),
signing_algorithm: Field.text({
label: 'Signing Algorithm',
required: false,
maxLength: 32,
description: 'JWS algorithm used to sign access tokens for this resource',
}),
signing_key_id: Field.text({
label: 'Signing Key ID',
required: false,
maxLength: 255,
description: 'Key id (kid) used to sign access tokens for this resource',
}),
allowed_scopes: Field.textarea({
label: 'Allowed Scopes',
required: false,
description: 'JSON-serialized list of scopes clients may request for this resource',
}),
custom_claims: Field.textarea({
label: 'Custom Claims',
required: false,
description: 'JSON object of extra claims stamped on access tokens for this resource',
}),
dpop_bound_access_tokens_required: Field.boolean({
label: 'DPoP Required',
required: false,
defaultValue: false,
description: 'Require access tokens for this resource to be DPoP-bound (RFC 9449)',
}),
disabled: Field.boolean({
label: 'Disabled',
required: false,
defaultValue: false,
}),
policy_version: Field.number({
label: 'Policy Version',
required: false,
defaultValue: 1,
description: 'Monotonic version of the resource token policy',
}),
metadata: Field.textarea({
label: 'Metadata',
required: false,
description: 'JSON object of additional resource metadata',
}),
created_at: Field.datetime({
label: 'Created At',
defaultValue: 'NOW()',
readonly: true,
}),
updated_at: Field.datetime({
label: 'Updated At',
defaultValue: 'NOW()',
readonly: true,
}),
},
indexes: [
{ fields: ['identifier'], unique: true },
],
enable: {
trackHistory: false,
searchable: false,
apiEnabled: false,
apiMethods: [],
},
});