2023-12-12 18:42:50 +01:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/urfave/cli"
|
2024-01-13 16:27:05 +01:00
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/pkg/authn"
|
2023-12-12 18:42:50 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// Usage hints for the client management subcommands.
|
|
|
|
const (
|
|
|
|
ClientNameUsage = "arbitrary name to help identify the `CLIENT` application"
|
2024-01-05 16:31:07 +01:00
|
|
|
ClientAuthScope = "authorization `SCOPE` of the client e.g. \"metrics\" or \"photos albums\" (\"*\" to allow all scopes)"
|
2024-01-13 16:27:05 +01:00
|
|
|
ClientAuthMethod = "supported authentication `METHOD` for the client application"
|
2024-01-05 16:31:07 +01:00
|
|
|
ClientAuthExpires = "access token lifetime in `SECONDS`, after which a new token must be created by the client (-1 to disable)"
|
|
|
|
ClientAuthTokens = "maximum `NUMBER` of access tokens the client can create (-1 to disable)"
|
2023-12-12 18:42:50 +01:00
|
|
|
ClientRegenerateSecret = "generate a new client secret and display it"
|
|
|
|
ClientDisable = "deactivate authentication with this client"
|
|
|
|
ClientEnable = "re-enable client authentication"
|
|
|
|
)
|
|
|
|
|
2024-01-02 17:06:57 +01:00
|
|
|
// ClientsCommands configures the client application subcommands.
|
|
|
|
var ClientsCommands = cli.Command{
|
2024-01-05 16:31:07 +01:00
|
|
|
Name: "clients",
|
|
|
|
Aliases: []string{"client"},
|
|
|
|
Usage: "Client credentials subcommands",
|
2023-12-12 18:42:50 +01:00
|
|
|
Subcommands: []cli.Command{
|
|
|
|
ClientsListCommand,
|
|
|
|
ClientsAddCommand,
|
|
|
|
ClientsShowCommand,
|
|
|
|
ClientsModCommand,
|
|
|
|
ClientsRemoveCommand,
|
|
|
|
ClientsResetCommand,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClientAddFlags specifies the "photoprism client add" command flags.
|
|
|
|
var ClientAddFlags = []cli.Flag{
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "name, n",
|
|
|
|
Usage: ClientNameUsage,
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "scope, s",
|
|
|
|
Usage: ClientAuthScope,
|
|
|
|
},
|
2024-01-13 16:27:05 +01:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "method, m",
|
|
|
|
Usage: ClientAuthMethod,
|
|
|
|
Value: authn.MethodOAuth2.String(),
|
|
|
|
Hidden: true,
|
|
|
|
},
|
2023-12-12 18:42:50 +01:00
|
|
|
cli.Int64Flag{
|
|
|
|
Name: "expires, e",
|
|
|
|
Usage: ClientAuthExpires,
|
|
|
|
},
|
|
|
|
cli.Int64Flag{
|
|
|
|
Name: "tokens, t",
|
|
|
|
Usage: ClientAuthTokens,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClientModFlags specifies the "photoprism client mod" command flags.
|
|
|
|
var ClientModFlags = []cli.Flag{
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "name, n",
|
|
|
|
Usage: ClientNameUsage,
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "scope, s",
|
|
|
|
Usage: ClientAuthScope,
|
|
|
|
},
|
2024-01-13 16:27:05 +01:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "method, m",
|
|
|
|
Usage: ClientAuthMethod,
|
|
|
|
Value: authn.MethodOAuth2.String(),
|
|
|
|
Hidden: true,
|
|
|
|
},
|
2023-12-12 18:42:50 +01:00
|
|
|
cli.Int64Flag{
|
|
|
|
Name: "expires, e",
|
|
|
|
Usage: ClientAuthExpires,
|
|
|
|
},
|
|
|
|
cli.Int64Flag{
|
|
|
|
Name: "tokens, t",
|
|
|
|
Usage: ClientAuthTokens,
|
|
|
|
},
|
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "regenerate-secret, r",
|
|
|
|
Usage: ClientRegenerateSecret,
|
|
|
|
},
|
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "disable",
|
|
|
|
Usage: ClientDisable,
|
|
|
|
},
|
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "enable",
|
|
|
|
Usage: ClientEnable,
|
|
|
|
},
|
|
|
|
}
|