Skip to content

Commit

Permalink
Merge pull request #156 from smallstep/okta-support
Browse files Browse the repository at this point in the history
Address support on OIDC provisioners
  • Loading branch information
maraino authored Sep 20, 2019
2 parents 6b2c852 + ba40ce0 commit 66f7b45
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions command/oauth/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func init() {
},
cli.StringFlag{
Name: "listen",
Usage: "Callback listener URL",
Usage: "Callback listener <address> (e.g. \":10000\")",
},
cli.BoolFlag{
Name: "implicit",
Expand Down Expand Up @@ -292,6 +292,11 @@ func (o *options) Validate() error {
if o.Provider != "google" && !strings.HasPrefix(o.Provider, "https://") {
return errors.New("use a valid provider: google")
}
if o.CallbackListener != "" {
if _, _, err := net.SplitHostPort(o.CallbackListener); err != nil {
return errors.Wrapf(err, "invalid value '%s' for flag '--listen'", o.CallbackListener)
}
}
return nil
}

Expand Down Expand Up @@ -419,7 +424,14 @@ func (o *oauth) NewServer() (*httptest.Server, error) {
if o.CallbackListener == "" {
return httptest.NewServer(o), nil
}
l, err := net.Listen("tcp", o.CallbackListener)
host, port, err := net.SplitHostPort(o.CallbackListener)
if err != nil {
return nil, err
}
if host == "" {
host = "127.0.0.1"
}
l, err := net.Listen("tcp", net.JoinHostPort(host, port))
if err != nil {
return nil, errors.Wrapf(err, "error listening on %s", o.CallbackListener)
}
Expand Down
2 changes: 1 addition & 1 deletion token/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type Payload struct {
IdentityProvider string `json:"idp"`
ObjectID string `json:"oid"`
TenantID string `json:"tid"`
Version string `json:"ver"`
Version interface{} `json:"ver"`
XMSMirID string `json:"xms_mirid"`
Google *GCPGooglePayload `json:"google"` // GCP token claims
Amazon *AWSAmazonPayload `json:"amazon"` // AWS token claims
Expand Down
12 changes: 9 additions & 3 deletions utils/cautils/offline.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,16 @@ func (c *OfflineCA) GenerateToken(ctx *cli.Context, typ int, subject string, san

switch p := p.(type) {
case *provisioner.OIDC: // Run step oauth
var out []byte
out, err = exec.Step("oauth", "--oidc", "--bare",
args := []string{"oauth", "--oidc", "--bare",
"--provider", p.ConfigurationEndpoint,
"--client-id", p.ClientID, "--client-secret", p.ClientSecret)
"--client-id", p.ClientID, "--client-secret", p.ClientSecret}
if ctx.Bool("console") {
args = append(args, "--console")
}
if p.ListenAddress != "" {
args = append(args, "--listen", p.ListenAddress)
}
out, err := exec.Step(args...)
if err != nil {
return "", err
}
Expand Down
5 changes: 4 additions & 1 deletion utils/cautils/token_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,12 @@ func NewTokenFlow(ctx *cli.Context, typ int, subject string, sans []string, caUR
args := []string{"oauth", "--oidc", "--bare",
"--provider", p.ConfigurationEndpoint,
"--client-id", p.ClientID, "--client-secret", p.ClientSecret}
if ctx.IsSet("console") {
if ctx.Bool("console") {
args = append(args, "--console")
}
if p.ListenAddress != "" {
args = append(args, "--listen", p.ListenAddress)
}
out, err := exec.Step(args...)
if err != nil {
return "", err
Expand Down

0 comments on commit 66f7b45

Please sign in to comment.