|
6 | 6 | package cli |
7 | 7 |
|
8 | 8 | import ( |
| 9 | + "encoding/json" |
9 | 10 | "errors" |
10 | 11 | "fmt" |
11 | 12 | "os" |
@@ -40,6 +41,7 @@ const ( |
40 | 41 | flagsAuthRevokeToken = "revoke_token" |
41 | 42 | flagsAuthRoleShow = "role_show" |
42 | 43 | flagsAuthConfShow = "conf_show" |
| 44 | + flagsAuthOIDCShow = "oidc_show" |
43 | 45 | ) |
44 | 46 |
|
45 | 47 | const authnUnreachable = `AuthN unreachable at %s. You may need to update AIS CLI configuration or environment variable %s` |
|
53 | 55 | flagsAuthRevokeToken: {tokenFileFlag}, |
54 | 56 | flagsAuthUserShow: {nonverboseFlag, verboseFlag}, |
55 | 57 | flagsAuthRoleShow: {nonverboseFlag, verboseFlag, clusterFilterFlag}, |
56 | | - flagsAuthConfShow: {jsonFlag}, |
| 58 | + flagsAuthConfShow: {jsonFlag, noHeaderFlag}, |
| 59 | + flagsAuthOIDCShow: {jsonFlag, noHeaderFlag}, |
57 | 60 | } |
58 | 61 |
|
59 | 62 | // define separately to allow for aliasing (see alias_hdlr.go) |
|
88 | 91 | Flags: sortFlags(authFlags[flagsAuthConfShow]), |
89 | 92 | Action: wrapAuthN(showAuthConfigHandler), |
90 | 93 | }, |
| 94 | + { |
| 95 | + Name: cmdAuthOIDC, |
| 96 | + Usage: "Show AuthN OIDC configuration", |
| 97 | + Flags: sortFlags(authFlags[flagsAuthOIDCShow]), |
| 98 | + Action: wrapAuthN(showAuthOIDCHandler), |
| 99 | + }, |
| 100 | + { |
| 101 | + Name: cmdAuthJWKS, |
| 102 | + Usage: "Show AuthN public JWKS", |
| 103 | + Action: wrapAuthN(showAuthJWKSHandler), |
| 104 | + }, |
91 | 105 | }, |
92 | 106 | } |
93 | 107 |
|
@@ -727,6 +741,37 @@ func showAuthConfigHandler(c *cli.Context) (err error) { |
727 | 741 | } |
728 | 742 | } |
729 | 743 |
|
| 744 | +func showAuthOIDCHandler(c *cli.Context) (err error) { |
| 745 | + oidc, err := authn.GetOIDCConfig(authParams) |
| 746 | + if err != nil { |
| 747 | + return err |
| 748 | + } |
| 749 | + list := flattenJSON(oidc, "") |
| 750 | + usejs := flagIsSet(c, jsonFlag) |
| 751 | + switch { |
| 752 | + case usejs: |
| 753 | + return teb.Print(oidc, teb.PropValTmpl, teb.Jopts(usejs)) |
| 754 | + case flagIsSet(c, noHeaderFlag): |
| 755 | + return teb.Print(list, teb.PropValTmplNoHdr) |
| 756 | + default: |
| 757 | + return teb.Print(list, teb.PropValTmpl) |
| 758 | + } |
| 759 | +} |
| 760 | + |
| 761 | +func showAuthJWKSHandler(_ *cli.Context) (err error) { |
| 762 | + rawJSON, err := authn.GetJWKS(authParams) |
| 763 | + if err != nil { |
| 764 | + return err |
| 765 | + } |
| 766 | + |
| 767 | + // Decode into a generic map for flattening / table output |
| 768 | + var jwks any |
| 769 | + if err := json.Unmarshal(*rawJSON, &jwks); err != nil { |
| 770 | + return err |
| 771 | + } |
| 772 | + return teb.Print(jwks, teb.PropValTmpl, teb.Jopts(true)) |
| 773 | +} |
| 774 | + |
730 | 775 | func authNConfigFromArgs(c *cli.Context) (conf *authn.ConfigToUpdate, err error) { |
731 | 776 | conf = &authn.ConfigToUpdate{Server: &authn.ServerConfToSet{}} |
732 | 777 | items := c.Args() |
|
0 commit comments