feat: add cmd openid-conf
This commit is contained in:
		
							parent
							
								
									21a2b5aa26
								
							
						
					
					
						commit
						fc9035148c
					
				
					 1 changed files with 40 additions and 29 deletions
				
			
		
							
								
								
									
										13
									
								
								app.ts
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								app.ts
									
										
									
									
									
								
							| 
						 | 
					@ -21,7 +21,7 @@ async function main() {
 | 
				
			||||||
            .version("0.1.0")
 | 
					            .version("0.1.0")
 | 
				
			||||||
            .description("Interactive client credentials generator for Forgejo.")
 | 
					            .description("Interactive client credentials generator for Forgejo.")
 | 
				
			||||||
            .command("login", "Authenticate with Forgejo interactively")
 | 
					            .command("login", "Authenticate with Forgejo interactively")
 | 
				
			||||||
            .action(async() => {
 | 
					            .action(async () => {
 | 
				
			||||||
                const username = await prompt("Enter your username: ");
 | 
					                const username = await prompt("Enter your username: ");
 | 
				
			||||||
                if (!username) {
 | 
					                if (!username) {
 | 
				
			||||||
                    console.error("Username is required.");
 | 
					                    console.error("Username is required.");
 | 
				
			||||||
| 
						 | 
					@ -224,6 +224,17 @@ async function main() {
 | 
				
			||||||
                    await saveSecretKeys(path, app.client_id, app.client_secret);
 | 
					                    await saveSecretKeys(path, app.client_id, app.client_secret);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            })
 | 
					            })
 | 
				
			||||||
 | 
					            .command("fetch-config", "Fetch OpenID configuration")
 | 
				
			||||||
 | 
					            .action(async () => {
 | 
				
			||||||
 | 
					                const response = await fetch(`${URL_BASE}/.well-known/openid-configuration`);
 | 
				
			||||||
 | 
					                if (!response.ok) {
 | 
				
			||||||
 | 
					                    console.error("Failed to fetch OpenID configuration:", response.statusText);
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                const config = await response.json();
 | 
				
			||||||
 | 
					                console.log("OpenID Configuration:", JSON.stringify(config, null, 2));
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
            .parse(Deno.args);
 | 
					            .parse(Deno.args);
 | 
				
			||||||
    } catch (error) {
 | 
					    } catch (error) {
 | 
				
			||||||
        if (error instanceof Error) {
 | 
					        if (error instanceof Error) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue