2 // Table Initialization
3 // First make sure the keyspace exists.
11 // Namespace - establish hierarchical authority to modify
12 // Permissions and Roles
13 // "scope" is flag to determine Policy. Typical important scope
17 scope int, // deprecated 2.0.11
23 CREATE INDEX ns_parent on ns(parent);
25 CREATE TABLE ns_attrib (
31 create index ns_attrib_key on ns_attrib(key);
37 perms set<varchar>, // Use "Key" of "name|type|action"
41 CREATE INDEX role_name ON role(name);
49 roles set<varchar>, // Need to find Roles given Permissions
51 PRIMARY KEY (ns,type,instance,action)
54 // This table is user for Authorization
55 CREATE TABLE user_role (
57 role varchar, // deprecated: change to ns/rname after 2.0.11
61 PRIMARY KEY(user,role)
63 CREATE INDEX user_role_ns ON user_role(ns);
64 CREATE INDEX user_role_role ON user_role(role);
66 // This table is only for the case where return User Credential (MechID) Authentication
76 PRIMARY KEY (id,type,expires)
78 CREATE INDEX cred_ns ON cred(ns);
80 // Certificate Cross Table
81 // coordinated with CRED type 2
87 PRIMARY KEY (fingerprint)
89 CREATE INDEX cert_id ON cert(id);
90 CREATE INDEX cert_x500 ON cert(x500);
97 PRIMARY KEY (user,type)
106 PRIMARY KEY (ca,serial)
110 CREATE INDEX x509_id ON x509 (id);
111 CREATE INDEX x509_x500 ON x509 (x500);
114 // Deployment Artifact (for Certman)
116 CREATE TABLE artifact (
129 PRIMARY KEY (mechid,machine)
131 CREATE INDEX artifact_machine ON artifact(machine);
132 CREATE INDEX artifact_ns ON artifact(ns);
135 // Non-Critical Table functions
137 // Table Info - for Caching
140 seg int, // cache Segment
142 PRIMARY KEY(name,seg)
145 CREATE TABLE history (
150 target varchar, // user, user_role,
151 subject varchar, // field for searching main portion of target key
152 memo varchar, //description of the action
153 reconstruct blob, //serialized form of the target
154 // detail Map<varchar, varchar>, // additional information
157 CREATE INDEX history_yr_mon ON history(yr_mon);
158 CREATE INDEX history_user ON history(user);
159 CREATE INDEX history_subject ON history(subject);
162 // A place to hold objects to be created at a future time.
164 CREATE TABLE future (
166 target varchar, // Target Table
167 memo varchar, // Description
168 start timestamp, // When it should take effect
169 expires timestamp, // When not longer valid
170 construct blob, // How to construct this object (like History)
173 CREATE INDEX future_idx ON future(target);
174 CREATE INDEX future_start_idx ON future(start);
177 CREATE TABLE approval (
178 id timeuuid, // unique Key
179 ticket uuid, // Link to Future Record
180 user varchar, // the user who needs to be approved
181 approver varchar, // user approving
182 type varchar, // approver types i.e. Supervisor, Owner
183 status varchar, // approval status. pending, approved, denied
184 memo varchar, // Text for Approval to know what's going on
185 operation varchar, // List operation to perform
186 last_notified timestamp, // Timestamp for the last time approver was notified
189 CREATE INDEX appr_approver_idx ON approval(approver);
190 CREATE INDEX appr_user_idx ON approval(user);
191 CREATE INDEX appr_ticket_idx ON approval(ticket);
192 CREATE INDEX appr_status_idx ON approval(status);
194 CREATE TABLE approved (
195 id timeuuid, // unique Key
196 user varchar, // the user who needs to be approved
197 approver varchar, // user approving
198 type varchar, // approver types i.e. Supervisor, Owner
199 status varchar, // approval status. pending, approved, denied
200 memo varchar, // Text for Approval to know what's going on
201 operation varchar, // List operation to perform
204 CREATE INDEX approved_approver_idx ON approved(approver);
205 CREATE INDEX approved_user_idx ON approved(user);
207 CREATE TABLE delegate (
213 CREATE INDEX delg_delg_idx ON delegate(delegate);
216 CREATE TABLE oauth_token (
217 id text, // Reference
218 client_id text, // Creating Client ID
219 user text, // User requesting
220 active boolean, // Active or not
221 type int, // Type of Token
222 refresh text, // Refresh Token
223 expires timestamp, // Expiration time/Date (signed long)
224 exp_sec bigint, // Seconds from Jan 1, 1970
225 content text, // Content of Token
226 scopes Set<text>, // Scopes
227 state text, // Context string (Optional)
228 req_ip text, // Requesting IP (for logging purpose)
230 ) with default_time_to_live = 21600; // 6 hours
231 CREATE INDEX oauth_token_user_idx ON oauth_token(user);
233 CREATE TABLE locate (
234 name text, // Component/Server name
235 hostname text, // FQDN of Service/Component
236 port int, // Port of Service
237 major int, // Version, Major
238 minor int, // Version, Minor
239 patch int, // Version, Patch
240 pkg int, // Version, Package (if available)
241 latitude float, // Latitude
242 longitude float, // Longitude
243 protocol text, // Protocol (i.e. http https)
244 subprotocol set<text>, // Accepted SubProtocols, ie. TLS1.1 for https
245 port_key uuid, // Key into locate_ports
246 PRIMARY KEY(name,hostname,port)
247 ) with default_time_to_live = 1200; // 20 mins
249 CREATE TABLE locate_ports (
250 id uuid, // Id into locate
252 name text, // Name of Other Port
253 protocol text, // Protocol of Other (i.e. JMX, DEBUG)
254 subprotocol set<text>, // Accepted sub protocols or versions
255 PRIMARY KEY(id, port)
256 ) with default_time_to_live = 1200; // 20 mins;
259 // Used by authz-batch processes to ensure only 1 runs at a time
261 CREATE TABLE run_lock (
265 PRIMARY KEY ((class))
268 CREATE TABLE config (
272 PRIMARY KEY (name,tag)