Fields of the APIToken.
()
| 33 | |
| 34 | // Fields of the APIToken. |
| 35 | func (APIToken) Fields() []ent.Field { |
| 36 | return []ent.Field{ |
| 37 | // API token identifier |
| 38 | field.UUID("id", uuid.UUID{}).Default(uuid.New).Unique(), |
| 39 | field.String("name").Immutable(), |
| 40 | // Optional description |
| 41 | field.String("description").Optional(), |
| 42 | field.Time("created_at").Default(time.Now).Immutable().Annotations(&entsql.Annotation{Default: "CURRENT_TIMESTAMP"}), |
| 43 | field.Time("expires_at").Optional(), |
| 44 | // the token can be manually revoked |
| 45 | field.Time("revoked_at").Optional(), |
| 46 | field.Time("last_used_at").Optional(), |
| 47 | // if this value is not set, the token is an instance-level token |
| 48 | field.UUID("organization_id", uuid.UUID{}).Optional(), |
| 49 | // Tokens can be associated with a project |
| 50 | // if this value is not set, the token is an organization level token |
| 51 | field.UUID("project_id", uuid.UUID{}).Optional(), |
| 52 | // Tokens can additionally be scoped to a specific workflow within a project. |
| 53 | // Only meaningful when project_id is also set. |
| 54 | field.UUID("workflow_id", uuid.UUID{}).Optional(), |
| 55 | // ACL policies for this token. NULL means role-based token (future), non-NULL means ACL mode. |
| 56 | // When set, contains the list of policies this token is allowed to perform. |
| 57 | field.JSON("policies", []*authz.Policy{}).Optional(), |
| 58 | // System tokens are minted by internal code paths and hidden from the public API. |
| 59 | field.Bool("is_system").Default(false).Immutable(), |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | func (APIToken) Edges() []ent.Edge { |
| 64 | return []ent.Edge{ |