forked from dexidp/dex
/
keys.go
45 lines (39 loc) · 966 Bytes
/
keys.go
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
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/field"
"gopkg.in/square/go-jose.v2"
"github.com/sgalsaleh/dex/v2/storage"
)
/* Original SQL table:
create table keys
(
id text not null primary key,
verification_keys blob not null,
signing_key blob not null,
signing_key_pub blob not null,
next_rotation timestamp not null
);
*/
// Keys holds the schema definition for the Keys entity.
type Keys struct {
ent.Schema
}
// Fields of the Keys.
func (Keys) Fields() []ent.Field {
return []ent.Field{
field.Text("id").
SchemaType(textSchema).
NotEmpty().
Unique(),
field.JSON("verification_keys", []storage.VerificationKey{}),
field.JSON("signing_key", jose.JSONWebKey{}),
field.JSON("signing_key_pub", jose.JSONWebKey{}),
field.Time("next_rotation").
SchemaType(timeSchema),
}
}
// Edges of the Keys.
func (Keys) Edges() []ent.Edge {
return []ent.Edge{}
}