Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option of using OpenSSL for authentication between RTI and federates #1432

Merged
merged 62 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
32eb917
Added HMAC authentication between RTI and federates, using federation…
Jakio815 Sep 27, 2022
68085e9
Target Config for auth is set false. auth option is useable for targe…
Jakio815 Oct 5, 2022
750ea8b
Added SimpleFederatedAuth.lf for test of auth option
Jakio815 Oct 5, 2022
573ad15
Added generating -a option to RTI
Jakio815 Oct 5, 2022
e46d858
Added FEDERATED_AUTH when targetConfig.auth is true
Jakio815 Oct 6, 2022
cb958c0
updated submodule
Jakio815 Oct 6, 2022
2d3224b
Merge branch 'master' into auth
Jakio815 Oct 6, 2022
bd058c5
Fixed comments for target property AUTH
Jakio815 Oct 6, 2022
152b9d2
Make definition for federate authentication more readable.
hokeun Oct 7, 2022
feaa943
Rename the authentication test to make it more descriptive. Add DEBUG…
hokeun Oct 8, 2022
d9d1aec
Update reactor-c submodule.
hokeun Oct 8, 2022
8433132
Add comments and DEBUG logging to SimpleFederatedAuthenticated.lf.
hokeun Oct 19, 2022
8bb1842
Merge branch 'master' of github.com:lf-lang/lingua-franca into auth
hokeun Oct 19, 2022
fce6884
Added comments
Jakio815 Oct 30, 2022
f38f04b
Merge branch 'master' of github.com:lf-lang/lingua-franca into auth
Jakio815 Oct 30, 2022
f99e61c
Add fixmes to update auth option type from boolean to string.
Jakio815 Oct 31, 2022
678fccb
Merge branch 'master' of github.com:lf-lang/lingua-franca into auth
Jakio815 Nov 10, 2022
3907b22
Merge branch 'master' of github.com:lf-lang/lingua-franca into auth
Jakio815 Nov 13, 2022
494812c
Add PRIVATE keyword to openssl code generator.
Nov 13, 2022
c7511b9
Updated reactor-c version
Jakio815 Nov 14, 2022
5363089
Add -DAUTH=ON for tests
Nov 16, 2022
8c1f403
Update reactor-c version
Nov 16, 2022
d50dc23
Update reactor-c version
Nov 16, 2022
308554e
Add mac os dependency openssl
Nov 16, 2022
eb5da4b
Formatting SimpleFederatedAuthenticated.lf
Nov 16, 2022
7177e4e
Added cmake mac options
Nov 16, 2022
ae37da5
Minor revisions
Nov 16, 2022
c95a258
Test CI Tests
Nov 16, 2022
d889a47
Add openssl mac links
Nov 17, 2022
fefcc12
changed test branch temporarily
Nov 17, 2022
085dd9e
Formatted SimpleFederatedAuthenticated.lf
Nov 17, 2022
04ee608
Merge branch 'master' of github.com:lf-lang/lingua-franca into auth
Nov 18, 2022
cf12709
add path to mac dependencies
Nov 18, 2022
2741cfd
Addmore to mac dependencies
Nov 18, 2022
0238862
Added mac os options in cmake generator
Nov 18, 2022
f35c0c3
Test Mac environment
Nov 19, 2022
a998c89
Fix bugs
Nov 19, 2022
0568180
Buf fix
Nov 19, 2022
4e7c972
Add exports
Nov 19, 2022
26ac623
Added CCPP target properties
Nov 20, 2022
b5f7602
Test shorter tests
Nov 21, 2022
dbb2970
Bug fix
Nov 21, 2022
ef7f66f
Bug fix
Nov 21, 2022
c8674b1
Test added
Nov 21, 2022
81edc54
FIx bugs
Nov 21, 2022
8248a60
FIX bugs
Nov 21, 2022
a9b91c9
Change orders of finding openssl
Nov 21, 2022
8f452c2
Changed to SET path
Nov 21, 2022
2160e58
Remove unneeded lines
Nov 21, 2022
2b272ac
Restore ci tests
Nov 21, 2022
b41dbca
Restore ci tests
Nov 21, 2022
9251b9c
Update reactor-c
Nov 21, 2022
f12b27f
Test export
Nov 21, 2022
00d5164
Fix bugs
Nov 21, 2022
88e1a46
FIX bugs
Nov 21, 2022
7082ffc
FIX bugs
Nov 21, 2022
d3565d3
Testing variables
Nov 21, 2022
a82a76f
Restore git CI tests
Nov 21, 2022
896ad59
Fix bugs
Nov 21, 2022
49a7aaf
Merge branch 'master' into auth
Jakio815 Nov 22, 2022
7ffc785
Removed Fixmes
Dec 20, 2022
524e556
Merge branch 'master' of github.com:lf-lang/lingua-franca into auth
Dec 20, 2022
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
5 changes: 4 additions & 1 deletion .github/actions/install-rti/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
cd org.lflang/src/lib/c/reactor-c/core/federated/RTI
mkdir build
cd build
cmake ../
if [[ "$OSTYPE" == "darwin"* ]]; then
export OPENSSL_ROOT_DIR="/usr/local/opt/openssl"
fi
cmake -DAUTH=ON ../
make
sudo make install
2 changes: 2 additions & 0 deletions .github/workflows/c-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
- name: Install dependencies OS X
run: |
brew install coreutils
brew install openssl
brew link openssl --force
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only adding export OPENSSL_ROOT_DIR="/usr/local/opt/openssl" does not work, because it seems that every run opens a new bash.

if: ${{ runner.os == 'macOS' }}
- name: Install RTI
uses: ./.github/actions/install-rti
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ jobs:

# Run the C integration tests.
c-tests:
uses: lf-lang/lingua-franca/.github/workflows/c-tests.yml@master
uses: lf-lang/lingua-franca/.github/workflows/c-tests.yml@auth
needs: cancel

# Run the CCpp integration tests.
ccpp-tests:
uses: lf-lang/lingua-franca/.github/workflows/c-tests.yml@master
uses: lf-lang/lingua-franca/.github/workflows/c-tests.yml@auth
lhstrh marked this conversation as resolved.
Show resolved Hide resolved
with:
use-cpp: true
needs: cancel
Expand Down
5 changes: 5 additions & 0 deletions org.lflang/src/org/lflang/TargetConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ public class TargetConfig {
*/
public int workers = 0;

/**
* Indicate whether HMAC authentication is used.
*/
public boolean auth = false;

/**
* Indicate whether the runtime should use multithreaded execution.
*/
Expand Down
8 changes: 7 additions & 1 deletion org.lflang/src/org/lflang/TargetProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@
* @author{Marten Lohstroh <[email protected]>}
*/
public enum TargetProperty {

/**
* Directive to allow including OpenSSL libraries and process HMAC authentication.
*/
AUTH("auth", PrimitiveType.BOOLEAN,
Arrays.asList(Target.C, Target.CCPP), (config, value, err) -> {
config.auth = ASTUtils.toBoolean(value);
}),

/**
* Directive to let the generator use the custom build command.
Expand Down
3 changes: 3 additions & 0 deletions org.lflang/src/org/lflang/federated/launcher/FedLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ private String getRtiCommand(List<FederateInstance> federates, boolean isRemote)
} else {
commands.add("RTI -i ${FEDERATION_ID} \\");
}
if (targetConfig.auth) {
commands.add(" -a \\");
}
commands.addAll(List.of(
" -n "+federates.size()+" \\",
" -c "+targetConfig.clockSync.toString()+" \\"
Expand Down
16 changes: 16 additions & 0 deletions org.lflang/src/org/lflang/generator/c/CCmakeGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ CodeBuilder generateCMakeCode(
cMakeCode.pr("target_include_directories(${LF_MAIN_TARGET} PUBLIC include/core/modal_models)");
cMakeCode.pr("target_include_directories(${LF_MAIN_TARGET} PUBLIC include/core/utils)");

if(targetConfig.auth) {
// If security is requested, add the auth option.
var osName = System.getProperty("os.name").toLowerCase();
// if platform target was set, use given platform instead
if (targetConfig.platformOptions.platform != Platform.AUTO) {
osName = targetConfig.platformOptions.platform.toString();
}
if (osName.contains("mac")) {
cMakeCode.pr("set(OPENSSL_ROOT_DIR /usr/local/opt/openssl)");
}
cMakeCode.pr("# Find OpenSSL and link to it");
cMakeCode.pr("find_package(OpenSSL REQUIRED)");
cMakeCode.pr("target_link_libraries( ${LF_MAIN_TARGET} PRIVATE OpenSSL::SSL)");
cMakeCode.newLine();
}

if (targetConfig.threading || targetConfig.tracing != null) {
// If threaded computation is requested, add the threads option.
cMakeCode.pr("# Find threads and link to it");
Expand Down
4 changes: 4 additions & 0 deletions org.lflang/src/org/lflang/generator/c/CGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ public void setCSpecificDefaults() {
if (isFederated) {
// Add compile definitions for federated execution
targetConfig.compileDefinitions.put("FEDERATED", "");
if(targetConfig.auth) {
// The federates are authenticated before joining federation.
targetConfig.compileDefinitions.put("FEDERATED_AUTHENTICATED", "");
}
if (targetConfig.coordination == CoordinationType.CENTRALIZED) {
// The coordination is centralized.
targetConfig.compileDefinitions.put("FEDERATED_CENTRALIZED", "");
Expand Down
23 changes: 23 additions & 0 deletions test/C/src/federated/SimpleFederatedAuthenticated.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* This simple test checks if federate authentication works by adding `auth`
* target property.
*/
target C {
timeout: 2 secs,
build-type: RelWithDebInfo,
auth: true,
logging: DEBUG
}

reactor Fed {
input in: int
output out: int
}

federated reactor {
fed1 = new Fed()
fed2 = new Fed()

fed1.out -> fed2.in
fed2.out -> fed1.in
}