forked from rsuddeth/okta-aws-cli-assume-role
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added WithOkta method and script, so that Terraform and other environments could connect to Okta and become Okta profiles. * Added WithOkta method and script, so that Terraform and other environments could connect to Okta and become Okta profiles. * Add withokta.bat batch file
- Loading branch information
Showing
6 changed files
with
126 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2017 Okta | ||
# | ||
# 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:https://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. | ||
# | ||
java -classpath .:oktaawscli.jar com.okta.tools.WithOkta $@ |
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,16 @@ | ||
rem | ||
rem Copyright 2017 Okta | ||
rem | ||
rem Licensed under the Apache License, Version 2.0 (the "License"); | ||
rem you may not use this file except in compliance with the License. | ||
rem You may obtain a copy of the License at | ||
rem | ||
rem http:https://www.apache.org/licenses/LICENSE-2.0 | ||
rem | ||
rem Unless required by applicable law or agreed to in writing, software | ||
rem distributed under the License is distributed on an "AS IS" BASIS, | ||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
rem See the License for the specific language governing permissions and | ||
rem limitations under the License. | ||
rem | ||
java -classpath .;oktaawscli.jar com.okta.tools.WithOkta %* |
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,37 @@ | ||
package com.okta.tools; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.Properties; | ||
|
||
final class OktaAwsConfig { | ||
static OktaAwsCliAssumeRole createAwscli() throws IOException { | ||
Properties properties = new Properties(); | ||
InputStream config; | ||
try { | ||
config = new FileInputStream("config.properties"); | ||
} catch (IOException ex) { | ||
// Fallback to classpath input stream | ||
config = properties.getClass().getResourceAsStream("/config.properties"); | ||
} | ||
properties.load(new InputStreamReader(config)); | ||
|
||
return OktaAwsCliAssumeRole.createOktaAwsCliAssumeRole( | ||
getEnvOrConfig(properties, "OKTA_ORG"), | ||
getEnvOrConfig(properties, "OKTA_AWS_APP_URL"), | ||
getEnvOrConfig(properties, "OKTA_USERNAME"), | ||
getEnvOrConfig(properties, "OKTA_PASSWORD"), | ||
getEnvOrConfig(properties, "OKTA_PROFILE"), | ||
getEnvOrConfig(properties, "OKTA_AWS_ROLE_TO_ASSUME") | ||
|
||
); | ||
} | ||
|
||
private static String getEnvOrConfig(Properties properties, String propertyName) { | ||
String envValue = System.getenv(propertyName); | ||
return envValue != null ? | ||
envValue : properties.getProperty(propertyName); | ||
} | ||
} |
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,32 @@ | ||
package com.okta.tools; | ||
|
||
import java.time.Instant; | ||
|
||
/* | ||
* Copyright 2017 Okta | ||
* | ||
* 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:https://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. | ||
*/ | ||
|
||
|
||
public class WithOkta { | ||
public static void main(String[] args) throws Exception { | ||
OktaAwsConfig.createAwscli().run(Instant.now()); | ||
ProcessBuilder awsProcessBuilder = new ProcessBuilder().inheritIO().command(args); | ||
Process awsSubProcess = awsProcessBuilder.start(); | ||
int exitCode = awsSubProcess.waitFor(); | ||
System.exit(exitCode); | ||
} | ||
|
||
} | ||
|
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