-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PKCE and public clients for authz code flow (#19)
* Initial commit for PKCE support * fix: IMS doesn't support public clients without PKCE * new pkce subcommand * Update dependencies
- Loading branch information
1 parent
9e5bb13
commit e6098e3
Showing
7 changed files
with
91 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2020 Adobe. All rights reserved. | ||
// This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. You may obtain a copy | ||
// of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed under | ||
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
// OF ANY KIND, either express or implied. See the License for the specific language | ||
// governing permissions and limitations under the License. | ||
|
||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/adobe/imscli/ims" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func authzUserPkceCmd(imsConfig *ims.Config) *cobra.Command { | ||
|
||
cmd := &cobra.Command{ | ||
Use: "pkce", | ||
Short: "Negotiate a normal user access token using PKCE.", | ||
Long: "Perform the 'Authorization Code Grant Flow with PKCE' by launching a browser and capturing the " + | ||
"returned IMS token. Public and private clients are supported.", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
cmd.SilenceUsage = true | ||
cmd.SilenceErrors = true | ||
imsConfig.PKCE = true | ||
resp, err := imsConfig.AuthorizeUser() | ||
if err != nil { | ||
return fmt.Errorf("error in user authorization: %v", err) | ||
} | ||
fmt.Println(resp) | ||
return nil | ||
}, | ||
} | ||
|
||
cmd.Flags().StringVarP(&imsConfig.ClientID, "clientID", "c", "", "IMS client ID.") | ||
cmd.Flags().StringVarP(&imsConfig.ClientSecret, "clientSecret", "p", "", "IMS client secret.") | ||
cmd.Flags().StringVarP(&imsConfig.Organization, "organization", "o", "", "IMS Organization.") | ||
cmd.Flags().StringSliceVarP(&imsConfig.Scopes, "scopes", "s", []string{""}, "Scopes to request.") | ||
cmd.Flags().BoolVarP(&imsConfig.PublicClient, "public", "b", false, "Public client, ignore secret.") | ||
//TODO: cmd.Flags().IntVarP(&imsConfig.Port, "port", "C", 8888, "Local port to be used by the OAuth Client.") | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ type Config struct { | |
Cascading bool | ||
Token string | ||
Port int | ||
PKCE bool | ||
} | ||
|
||
type TokenInfo struct { | ||
|