Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion cmd/lk/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const (
usageAdmin = "Ability to moderate a room (requires --room)"
usageEgress = "Ability to interact with Egress services"
usageIngress = "Ability to interact with Ingress services"
usageMetadata = "Ability to update their own name and metadata"
usageMetadata = "Ability to update their own name and metadata"
usageInference = "Ability to perform inference (AI endpoints)"
)

var (
Expand Down Expand Up @@ -82,6 +83,10 @@ var (
Name: "ingress",
Usage: usageIngress,
},
&cli.BoolFlag{
Name: "inference",
Usage: usageInference,
},
&cli.BoolFlag{
Name: "allow-update-metadata",
Usage: usageMetadata,
Expand Down Expand Up @@ -287,6 +292,10 @@ func createToken(ctx context.Context, c *cli.Command) error {
grant.IngressAdmin = true
hasPerms = true
}
inferenceGrant := c.Bool("inference")
if inferenceGrant {
hasPerms = true
}
if c.IsSet("allow-source") {
sourcesStr := c.StringSlice("allow-source")
sources := make([]livekit.TrackSource, 0, len(sourcesStr))
Expand Down Expand Up @@ -329,6 +338,7 @@ func createToken(ctx context.Context, c *cli.Command) error {
pAdmin
pEgress
pIngress
pInference
pMetadata
)

Expand All @@ -343,6 +353,7 @@ func createToken(ctx context.Context, c *cli.Command) error {
huh.NewOption("Admin", pAdmin),
huh.NewOption("Egress", pEgress),
huh.NewOption("Ingress", pIngress),
huh.NewOption("Inference", pInference),
huh.NewOption("Update metadata", pMetadata),
).
Title("Token Permissions").
Expand All @@ -362,6 +373,7 @@ func createToken(ctx context.Context, c *cli.Command) error {
grant.RoomRecord = true
}
grant.SetCanUpdateOwnMetadata(slices.Contains(permissions, pMetadata))
inferenceGrant = slices.Contains(permissions, pInference)
}
}

Expand All @@ -372,6 +384,10 @@ func createToken(ctx context.Context, c *cli.Command) error {

at := accessToken(project.APIKey, project.APISecret, grant, participant)

if inferenceGrant {
at.SetInferenceGrant(&auth.InferenceGrant{Perform: true})
}

if grant.RoomJoin {
if agent := c.String("agent"); agent != "" {
jobMetadata := c.String("job-metadata")
Expand Down