Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 18 additions & 2 deletions 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 Expand Up @@ -413,7 +429,7 @@ func createToken(ctx context.Context, c *cli.Command) error {
}

fmt.Println("Token grants:")
util.PrintJSON(grant)
util.PrintJSON(at.GetGrants())
fmt.Println()
if project.URL != "" {
fmt.Println("Project URL:", project.URL)
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
package livekitcli

const (
Version = "2.13.2"
Version = "2.14.0"
)
Loading