@@ -17,6 +17,9 @@ pub enum AuthCommands {
1717 /// The access token is part of the credentials produced by `rerun auth login`,
1818 /// and is used to authorize requests to the Rerun data platform.
1919 Token ( TokenCommand ) ,
20+
21+ /// Generate a fresh token.
22+ GenerateToken ( GenerateTokenCommand ) ,
2023}
2124
2225#[ derive( Debug , Clone , Parser ) ]
@@ -34,8 +37,21 @@ pub struct LoginCommand {
3437#[ derive( Debug , Clone , Parser ) ]
3538pub struct TokenCommand { }
3639
40+ #[ derive( Debug , Clone , Parser ) ]
41+ pub struct GenerateTokenCommand {
42+ /// Origin of the server to request the token from.
43+ #[ clap( long) ]
44+ server : String ,
45+
46+ /// Duration of the token, either in:
47+ /// - "human time", e.g. `1 day`, or
48+ /// - ISO 8601 duration format, e.g. `P1D`.
49+ #[ clap( long) ]
50+ expiration : jiff:: Span ,
51+ }
52+
3753impl AuthCommands {
38- pub fn run ( & self , runtime : & tokio:: runtime:: Handle ) -> Result < ( ) , re_auth:: cli:: Error > {
54+ pub fn run ( self , runtime : & tokio:: runtime:: Handle ) -> Result < ( ) , re_auth:: cli:: Error > {
3955 match self {
4056 Self :: Login ( args) => {
4157 let options = re_auth:: cli:: LoginOptions {
@@ -46,6 +62,17 @@ impl AuthCommands {
4662 }
4763
4864 Self :: Token ( _) => runtime. block_on ( re_auth:: cli:: token ( ) ) ,
65+
66+ Self :: GenerateToken ( args) => {
67+ let server = url:: Url :: parse ( & args. server )
68+ . map_err ( |err| re_auth:: cli:: Error :: Generic ( err. into ( ) ) ) ?
69+ . origin ( ) ;
70+ let options = re_auth:: cli:: GenerateTokenOptions {
71+ server,
72+ expiration : args. expiration ,
73+ } ;
74+ runtime. block_on ( re_auth:: cli:: generate_token ( options) )
75+ }
4976 }
5077 }
5178}
0 commit comments