Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/authz/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func ClientCredentialsCmd(imsConfig *ims.Config) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
cmd.SilenceUsage = true


resp, err := imsConfig.AuthorizeClientCredentials()
if err != nil {
return fmt.Errorf("error in login service: %w", err)
Expand All @@ -40,6 +39,8 @@ func ClientCredentialsCmd(imsConfig *ims.Config) *cobra.Command {
cmd.Flags().StringVarP(&imsConfig.ClientSecret, "clientSecret", "p", "", "IMS client secret.")
cmd.Flags().StringSliceVarP(&imsConfig.Scopes, "scopes", "s", []string{}, "Scopes to request.")
cmd.Flags().StringVarP(&imsConfig.Organization, "organization", "o", "", "IMS Organization.")
cmd.Flags().StringSliceVarP(&imsConfig.Resource, "resource", "r", nil,
"RFC 8707 resource indicator URI(s) for audience-restricted tokens.")

return cmd
}
2 changes: 2 additions & 0 deletions cmd/authz/pkce.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ func UserPkceCmd(imsConfig *ims.Config) *cobra.Command {
cmd.Flags().StringSliceVarP(&imsConfig.Scopes, "scopes", "s", []string{}, "Scopes to request.")
cmd.Flags().BoolVarP(&imsConfig.PublicClient, "public", "b", false, "Public client, ignore secret.")
cmd.Flags().IntVarP(&imsConfig.Port, "port", "l", 8888, "Local port to be used by the OAuth Client.")
cmd.Flags().StringSliceVarP(&imsConfig.Resource, "resource", "r", nil,
"RFC 8707 resource indicator URI(s) for audience-restricted tokens.")

return cmd
}
3 changes: 2 additions & 1 deletion cmd/authz/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func ServiceCmd(imsConfig *ims.Config) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
cmd.SilenceUsage = true


resp, err := imsConfig.AuthorizeService()
if err != nil {
return fmt.Errorf("error in login service: %w", err)
Expand All @@ -38,6 +37,8 @@ func ServiceCmd(imsConfig *ims.Config) *cobra.Command {
cmd.Flags().StringVarP(&imsConfig.ClientID, "clientID", "c", "", "IMS client ID.")
cmd.Flags().StringVarP(&imsConfig.ClientSecret, "clientSecret", "p", "", "IMS client secret.")
cmd.Flags().StringVarP(&imsConfig.AuthorizationCode, "authorizationCode", "x", "", "Permanent authorization code.")
cmd.Flags().StringSliceVarP(&imsConfig.Resource, "resource", "r", nil,
"RFC 8707 resource indicator URI(s) for audience-restricted tokens.")

return cmd
}
3 changes: 2 additions & 1 deletion cmd/authz/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func UserCmd(imsConfig *ims.Config) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
cmd.SilenceUsage = true


resp, err := imsConfig.AuthorizeUser()
if err != nil {
return fmt.Errorf("error in user authorization: %w", err)
Expand All @@ -43,6 +42,8 @@ func UserCmd(imsConfig *ims.Config) *cobra.Command {
cmd.Flags().StringVarP(&imsConfig.Organization, "organization", "o", "", "IMS Organization.")
cmd.Flags().StringSliceVarP(&imsConfig.Scopes, "scopes", "s", []string{}, "Scopes to request.")
cmd.Flags().IntVarP(&imsConfig.Port, "port", "l", 8888, "Local port to be used by the OAuth Client.")
cmd.Flags().StringSliceVarP(&imsConfig.Resource, "resource", "r", nil,
"RFC 8707 resource indicator URI(s) for audience-restricted tokens.")

return cmd
}
3 changes: 2 additions & 1 deletion cmd/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func exchangeCmd(imsConfig *ims.Config) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
cmd.SilenceUsage = true


resp, err := imsConfig.ClusterExchange()
if err != nil {
return fmt.Errorf("error exchanging the access token: %w", err)
Expand All @@ -46,6 +45,8 @@ func exchangeCmd(imsConfig *ims.Config) *cobra.Command {
cmd.Flags().StringSliceVarP(&imsConfig.Scopes, "scopes", "s", []string{},
"Scopes to request in the new token. Subset of the scopes of the original token. Optional value, if no "+
"scopes are requested the same scopes of the original token will be provided")
cmd.Flags().StringSliceVarP(&imsConfig.Resource, "resource", "r", nil,
"RFC 8707 resource indicator URI(s) for audience-restricted tokens.")

cmd.MarkFlagsMutuallyExclusive("organization", "userID")

Expand Down
2 changes: 2 additions & 0 deletions cmd/obo_exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ func oboExchangeCmd(imsConfig *ims.Config) *cobra.Command {
cmd.Flags().StringVarP(&imsConfig.AccessToken, "accessToken", "t", "", "User access token (subject token). Only access tokens are accepted.")
cmd.Flags().StringSliceVarP(&imsConfig.Scopes, "scopes", "s", nil,
"Optional scopes to request; if omitted, none are sent. When set, must stay within the client's configured scope boundary.")
cmd.Flags().StringSliceVarP(&imsConfig.Resource, "resource", "r", nil,
"RFC 8707 resource indicator URI(s) for audience-restricted tokens.")

return cmd
}
3 changes: 2 additions & 1 deletion cmd/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func refreshCmd(imsConfig *ims.Config) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
cmd.SilenceUsage = true


resp, err := imsConfig.Refresh()
if err != nil {
return fmt.Errorf("error during the token refresh: %w", err)
Expand Down Expand Up @@ -56,6 +55,8 @@ func refreshCmd(imsConfig *ims.Config) *cobra.Command {
"Scopes to request in the new token. Subset of the scopes of the original token. Optional value, if no "+
"scopes are requested the same scopes of the original token will be provided.")
cmd.Flags().BoolVarP(&imsConfig.FullOutput, "fullOutput", "F", false, "Output a JSON with access and refresh tokens.")
cmd.Flags().StringSliceVarP(&imsConfig.Resource, "resource", "r", nil,
"RFC 8707 resource indicator URI(s) for audience-restricted tokens.")

return cmd
}
1 change: 1 addition & 0 deletions ims/authz_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (i Config) AuthorizeClientCredentials() (string, error) {
Scope: i.Scopes,
GrantType: "client_credentials",
OrgID: i.Organization,
Resource: i.Resource,
})
if err != nil {
return "", fmt.Errorf("error requesting token: %w", err)
Expand Down
1 change: 1 addition & 0 deletions ims/authz_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (i Config) AuthorizeService() (string, error) {
ClientID: i.ClientID,
ClientSecret: i.ClientSecret,
Code: i.AuthorizationCode,
Resource: i.Resource,
})
if err != nil {
return "", fmt.Errorf("error requesting token: %w", err)
Expand Down
1 change: 1 addition & 0 deletions ims/authz_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func (i Config) authorizeUser(pkce bool) (string, error) {
ClientSecret: i.ClientSecret,
Scope: i.Scopes,
UsePKCE: pkce,
Resource: i.Resource,
RedirectURI: fmt.Sprintf("http://localhost:%d", i.Port),
OnError: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = fmt.Fprintln(w, `
Expand Down
3 changes: 2 additions & 1 deletion ims/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ type Config struct {
AuthSrc string
DecodeFulfillableData bool
ClientName string
RedirectURIs []string
RedirectURIs []string
Resource []string
}

// TokenInfo holds the response data from token-related IMS API calls.
Expand Down
1 change: 1 addition & 0 deletions ims/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (i Config) ClusterExchange() (TokenInfo, error) {
UserID: i.UserID,
OrgID: i.Organization,
Scopes: i.Scopes,
Resource: i.Resource,
})
if err != nil {
return TokenInfo{}, fmt.Errorf("error during the cluster exchange: %w", err)
Expand Down
1 change: 1 addition & 0 deletions ims/obo_exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (i Config) OBOExchange() (TokenInfo, error) {
ClientSecret: i.ClientSecret,
SubjectToken: i.AccessToken,
Scopes: i.Scopes,
Resource: i.Resource,
})
if err != nil {
return TokenInfo{}, fmt.Errorf("error during the On-Behalf-Of exchange: %w", err)
Expand Down
1 change: 1 addition & 0 deletions ims/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (i Config) Refresh() (RefreshInfo, error) {
ClientSecret: i.ClientSecret,
RefreshToken: i.RefreshToken,
Scope: i.Scopes,
Resource: i.Resource,
})
if err != nil {
return RefreshInfo{}, fmt.Errorf("error during the token refresh: %w", err)
Expand Down
Loading