Skip to content

Commit

Permalink
Merge 2cc643c into 00100a1
Browse files Browse the repository at this point in the history
  • Loading branch information
phsym committed Mar 30, 2022
2 parents 00100a1 + 2cc643c commit 534a4d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cmd/cli/handler_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,13 @@ func configureClientBase(cmd *cobra.Command, withAuth bool) *hydra.OryHydra {

ht.Transport = newTransport(cmd)
}

if withAuth {
if token := flagx.MustGetString(cmd, "access-token"); token != "" {
ht.DefaultAuthentication = httptransport.BearerToken(token)
} else if u.User != nil {
pass, _ := u.User.Password()
ht.DefaultAuthentication = httptransport.BasicAuth(u.User.Username(), pass)
}
}

Expand Down
5 changes: 4 additions & 1 deletion cmd/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ func NewClientsCmd() *cobra.Command {
cmd.PersistentFlags().Bool("fake-tls-termination", false, `Fake tls termination by adding "X-Forwarded-Proto: https" to http headers`)
cmd.PersistentFlags().Duration("fail-after", time.Minute, `Stop retrying after the specified duration`)
cmd.PersistentFlags().String("access-token", os.Getenv("OAUTH2_ACCESS_TOKEN"), "Set an access token to be used in the Authorization header, defaults to environment variable OAUTH2_ACCESS_TOKEN")
cmd.PersistentFlags().String("endpoint", os.Getenv("HYDRA_ADMIN_URL"), "Set the URL where Ory Hydra is hosted, defaults to environment variable HYDRA_ADMIN_URL. A unix socket can be set in the form unix:///path/to/socket")
cmd.PersistentFlags().String("endpoint", os.Getenv("HYDRA_ADMIN_URL"),
"Set the URL where Ory Hydra is hosted, defaults to environment variable HYDRA_ADMIN_URL. A unix socket can be set in the form unix:///path/to/socket.\n"+
"HTTP basic-auth can be set in the url (https://<user>:<password>@<hostname>/). It will however be ignored if --access-token is also set",
)
cmd.PersistentFlags().Bool("skip-tls-verify", false, "Foolishly accept TLS certificates signed by unknown certificate authorities")
return cmd
}

0 comments on commit 534a4d4

Please sign in to comment.