-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
384 additions
and
214 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,45 @@ | ||
@FIREFLY | ||
Feature: Managing credentials tokens from Identity Providers | ||
|
||
As a user | ||
I want to get credentials for Firefly with Okta as IdP | ||
|
||
Background: | ||
Given the default aruba exit timeout is 180 seconds | ||
|
||
Scenario Outline: request access token from IdP | ||
When I get credentials from "<identity-provider>" | ||
And I remember the output | ||
And it should output access token | ||
|
||
Examples: | ||
| identity-provider | | ||
| Okta | | ||
|
||
Scenario Outline: request access token from IdP in JSON format | ||
When I get credentials from "<identity-provider>" with -format json | ||
And I remember the output | ||
And it should output access token in JSON | ||
|
||
Examples: | ||
| identity-provider | | ||
| Okta | | ||
|
||
Scenario Outline: request access token from IdP using password flow | ||
When I get credentials from "<identity-provider>" with username and password | ||
And I remember the output | ||
And it should output access token | ||
|
||
Examples: | ||
| identity-provider | | ||
| Okta | | ||
|
||
@TODO # currently interactive mode is not working for Idp for Firefly | ||
Scenario Outline: request access token from IdP using password flow interactively | ||
When I interactively get credentials from "<identity-provider>" with username and no password | ||
And I remember the output | ||
And it should output access token | ||
|
||
Examples: | ||
| identity-provider | | ||
| Okta | |
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,51 @@ | ||
|
||
When(/^I( interactively)? get credentials from "(.*)"(?: with)?(.+)?$/) do |interactively, identity_provider, flags| | ||
|
||
idp_token_url = "" | ||
idp_user = "" | ||
idp_password = "" | ||
idp_client_id = "" | ||
idp_client_secret = "" | ||
idp_scope = "" | ||
|
||
case identity_provider | ||
when "Okta" | ||
idp_token_url = "#{ENV['OKTA_AUTH_SERVER']}/v1/token" | ||
idp_user = ENV['OKTA_CREDS_USR'] | ||
idp_password = ENV['OKTA_CREDS_PSW'] | ||
if flags === " username and no password" || flags === " username and password" | ||
idp_client_id = ENV['OKTA_CLIENT_ID_PASS'] | ||
else | ||
idp_client_id = ENV['OKTA_CLIENT_ID'] | ||
end | ||
idp_client_secret = ENV['OKTA_CLIENT_SECRET'] | ||
idp_scope = ENV['OKTA_SCOPE'] | ||
else | ||
fail(ArgumentError.new("Unknown Identity Provider: #{identity_provider}")) | ||
end | ||
|
||
if flags === " username and no password" | ||
cmd = "vcert getcred -platform firefly -token-url '#{idp_token_url}' -client-id '#{idp_client_id}'" + | ||
" -username '#{idp_user}' -scope '#{idp_scope}'" | ||
elsif flags === " username and password" | ||
cmd = "vcert getcred -platform firefly -token-url '#{idp_token_url}' -client-id '#{idp_client_id}'" + | ||
" -username '#{idp_user}' -password '#{idp_password}' -scope '#{idp_scope}'" | ||
else | ||
# client id is our default | ||
cmd = "vcert getcred -platform firefly -token-url '#{idp_token_url}'" + | ||
" -client-id '#{idp_client_id}' -client-secret #{idp_client_secret} -scope '#{idp_scope}' #{flags}" | ||
end | ||
|
||
if interactively | ||
Kernel.puts cmd | ||
steps %{ | ||
Then I run `#{cmd}` interactively | ||
And I type "#{idp_password}" | ||
Then the exit status should be 0 | ||
} | ||
else | ||
steps %{ | ||
Then I try to run `#{cmd}` | ||
} | ||
end | ||
end |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2023 Venafi, Inc. | ||
* | ||
* Licensed 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 CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package endpoint | ||
|
||
// Authentication provides a struct for authentication data. Either specify User and Password for Trust Protection Platform | ||
// or Firefly or ClientId and ClientSecret for Firefly or specify an APIKey for TLS Protect Cloud. | ||
type Authentication struct { | ||
User string `yaml:"-"` | ||
Password string `yaml:"-"` | ||
APIKey string `yaml:"apiKey,omitempty"` | ||
RefreshToken string `yaml:"refreshToken,omitempty"` | ||
Scope string `yaml:"scope,omitempty"` | ||
ClientId string `yaml:"clientId,omitempty"` | ||
ClientSecret string `yaml:"clientSecret,omitempty"` | ||
AccessToken string `yaml:"accessToken,omitempty"` | ||
ClientPKCS12 bool `yaml:"-"` | ||
// IdentityProvider specify the OAuth 2.0 which VCert will be working for authorization purposes | ||
IdentityProvider *OAuthProvider `yaml:"idP,omitempty"` | ||
} | ||
|
||
// OAuthProvider provides a struct for the OAuth 2.0 providers information | ||
type OAuthProvider struct { | ||
TokenURL string `yaml:"tokenURL,omitempty"` | ||
Audience string `yaml:"audience,omitempty"` | ||
} |
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
Oops, something went wrong.