Skip to content

Commit

Permalink
Fix issues found when testing with auth0
Browse files Browse the repository at this point in the history
  • Loading branch information
imduffy15 committed Dec 9, 2018
1 parent 8699faf commit 7c5a29c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions cli/authcode_client_impersonator.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type AuthcodeClientImpersonator struct {
config client.Config
ClientID string
ClientSecret string
Audience string
Scope string
Port int
Log Logger
Expand Down Expand Up @@ -49,6 +50,7 @@ func NewAuthcodeClientImpersonator(
config client.Config,
clientID string,
clientSecret string,
audience string,
scope string,
port int,
log Logger,
Expand All @@ -59,6 +61,7 @@ func NewAuthcodeClientImpersonator(
config: config,
ClientID: clientID,
ClientSecret: clientSecret,
Audience: audience,
Scope: scope,
Port: port,
BrowserLauncher: launcher,
Expand Down Expand Up @@ -98,6 +101,7 @@ func (aci AuthcodeClientImpersonator) Authorize() {
requestValues := url.Values{}
requestValues.Add("response_type", "code")
requestValues.Add("client_id", aci.ClientID)
requestValues.Add("audience", aci.Audience)
requestValues.Add("redirect_uri", aci.redirectURI())
requestValues.Add("scope", strings.Replace(aci.Scope, ",", " ", -1))
requestValues.Add("state", uuid.New().String())
Expand Down
3 changes: 2 additions & 1 deletion client/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ type Target struct {
}

type ClientContext struct {
ClientID string `json:"client_id"`
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
Token
}

Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
var (
scope string
clientSecret string
audience string
port int
force bool
)
Expand Down
10 changes: 6 additions & 4 deletions cmd/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func refreshContext(contextName string, cfg client.Config, log cli.Logger) error
return err
}
refreshClient := client.RefreshTokenClient{
ClientID: context.ClientID,
ClientID: context.ClientID,
ClientSecret: context.ClientSecret,
}
token, err := refreshClient.RequestToken(HTTPClient(), cfg, context.Token.RefreshToken)
if err != nil {
Expand Down Expand Up @@ -90,7 +91,7 @@ var getAuthcodeToken = &cobra.Command{
}
}
} else {
authCodeImp := cli.NewAuthcodeClientImpersonator(HTTPClient(), cfg, args[0], clientSecret, scope, port, log, open.Run)
authCodeImp := cli.NewAuthcodeClientImpersonator(HTTPClient(), cfg, args[0], clientSecret, audience, scope, port, log, open.Run)
go AuthcodeTokenCommandRun(done, args[0], authCodeImp, log)
<-done
}
Expand All @@ -99,8 +100,9 @@ var getAuthcodeToken = &cobra.Command{

func init() {
getAuthcodeToken.Flags().IntVarP(&port, "port", "p", 8080, "port on which to run local callback server")
getAuthcodeToken.Flags().StringVarP(&scope, "scope", "s", "openid,offline_access", "comma-separated scopes to request in token")
getAuthcodeToken.Flags().StringVarP(&clientSecret, "client_secret", "c", "", "client secret")
getAuthcodeToken.Flags().StringVarP(&scope, "scope", "s", "openid,offline_access", "comma-separated list of scopes, this will be used as the `scopes` query parameter when requesting the token.")
getAuthcodeToken.Flags().StringVarP(&clientSecret, "client_secret", "c", "", "this will be used as the `client_secret` query parameter when requesting the token.")
getAuthcodeToken.Flags().StringVarP(&audience, "audience", "a", "", "this will be used as the `audience` query parameter when requesting the token.")

getAuthcodeToken.Flags().BoolVarP(&force, "force", "f", false, "Forces a new token")
tokenCmd.AddCommand(getAuthcodeToken)
Expand Down

0 comments on commit 7c5a29c

Please sign in to comment.