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

Implement Declarative Auth Design for ballerina/http Module #155

Merged
merged 28 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
367d1a5
Merge branch 'master' of https://github.com/ballerina-platform/module…
ldclakmal Jan 13, 2021
f83726a
Merge branch 'master' of https://github.com/ballerina-platform/module…
ldclakmal Jan 13, 2021
d5bef18
Implement auth filter
ldclakmal Jan 13, 2021
276faf4
Update auth filter implementation
ldclakmal Jan 14, 2021
c36f593
Engage auth filter
ldclakmal Jan 14, 2021
1b86b17
Add unit tests for imperative auth design
ldclakmal Jan 14, 2021
d26b64c
Merge branch 'master' of https://github.com/ballerina-platform/module…
ldclakmal Jan 14, 2021
5200535
Fix a bug in unit tests
ldclakmal Jan 14, 2021
b417ce6
Merge branch 'master' of https://github.com/ballerina-platform/module…
ldclakmal Jan 15, 2021
c278e93
Merge branch 'master' of https://github.com/ballerina-platform/module…
ldclakmal Jan 15, 2021
56bb850
Merge branch 'master' of https://github.com/ballerina-platform/module…
ldclakmal Jan 16, 2021
58d7212
Rename unit test file
ldclakmal Jan 17, 2021
c83f0f0
Remove http filters
ldclakmal Jan 17, 2021
7cd730a
Update auth desugar implementation
ldclakmal Jan 17, 2021
da934ca
Merge branch 'master' of https://github.com/ballerina-platform/module…
ldclakmal Jan 17, 2021
9f01def
Update with header API change
ldclakmal Jan 17, 2021
370d57b
Merge branch 'master' of https://github.com/ballerina-platform/module…
ldclakmal Jan 18, 2021
1d1bf08
Update auth desugar implementation
ldclakmal Jan 18, 2021
ba17a95
Fix and improve auth declarative design test cases
ldclakmal Jan 18, 2021
59d3e26
Update auth desugar signature and related implementation
ldclakmal Jan 18, 2021
91f2ed0
Update auth unit tests
ldclakmal Jan 18, 2021
e53eed0
Merge branch 'master' of https://github.com/ballerina-platform/module…
ldclakmal Jan 18, 2021
ec865a9
Fix for client init API change
ldclakmal Jan 18, 2021
a5689b4
Merge branch 'master' of https://github.com/ballerina-platform/module…
ldclakmal Jan 19, 2021
fcf2db4
Update declarative design unit tests
ldclakmal Jan 19, 2021
f8f52ff
Refactor code
ldclakmal Jan 19, 2021
f1539c3
Refactor unit tests
ldclakmal Jan 19, 2021
549aec4
Merge branch 'master' of https://github.com/ballerina-platform/module…
ldclakmal Jan 19, 2021
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
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ext.stdlibOsVersion = project.stdlibOsVersion
ext.stdlibTaskVersion = project.stdlibTaskVersion
ext.stdlibUuidVersion = project.stdlibUuidVersion
ext.stdlibEncodingVersion = project.stdlibEncodingVersion
ext.stdlibReflectVersion = project.stdlibReflectVersion

ext.slf4jVersion = project.slf4jVersion
ext.ballerinaTomlParserVersion = project.ballerinaTomlParserVersion
Expand Down Expand Up @@ -193,6 +194,13 @@ allprojects {
password System.getenv("packagePAT")
}
}
maven {
url 'https://maven.pkg.github.com/ballerina-platform/module-ballerina-reflect'
credentials {
username System.getenv("packageUser")
password System.getenv("packagePAT")
}
}
}
}

Expand All @@ -216,6 +224,7 @@ subprojects {
ballerinaStdLibs "org.ballerinalang:crypto-ballerina:${stdlibCryptoVersion}"
ballerinaStdLibs "org.ballerinalang:file-ballerina:${stdlibFileVersion}"
ballerinaStdLibs "org.ballerinalang:config-ballerina:${stdlibConfigVersion}"
ballerinaStdLibs "org.ballerinalang:reflect-ballerina:${stdlibReflectVersion}"

// Transitive dependencies
ballerinaStdLibs "org.ballerinalang:os-ballerina:${stdlibOsVersion}"
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ stdlibJwtVersion=1.0.7-SNAPSHOT
stdlibOAuth2Version=1.0.5-SNAPSHOT
stdlibUuidVersion=0.9.1-SNAPSHOT
stdlibEncodingVersion=1.0.7-SNAPSHOT
stdlibReflectVersion=0.5.5-SNAPSHOT
16 changes: 8 additions & 8 deletions http-ballerina-tests/tests/auth_listener_auth_handler_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@ isolated function testListenerFileUserStoreBasicAuthHandlerAuthSuccess() {
auth:UserDetails|http:Unauthorized authn1 = handler.authenticate(request);
if (authn1 is auth:UserDetails) {
test:assertEquals(authn1.username, "alice");
test:assertEquals(authn1.scopes, ["read", "write"]);
test:assertEquals(authn1.scopes, ["write", "update"]);
} else {
test:assertFail(msg = "Test Failed!");
}

auth:UserDetails|http:Unauthorized authn2 = handler.authenticate(headerValue);
if (authn2 is auth:UserDetails) {
test:assertEquals(authn2.username, "alice");
test:assertEquals(authn2.scopes, ["read", "write"]);
test:assertEquals(authn2.scopes, ["write", "update"]);
} else {
test:assertFail(msg = "Test Failed!");
}

http:Forbidden? authz1 = handler.authorize(<auth:UserDetails>authn1, "read");
http:Forbidden? authz1 = handler.authorize(<auth:UserDetails>authn1, "write");
if (authz1 is http:Forbidden) {
test:assertFail(msg = "Test Failed!");
}

http:Forbidden? authz2 = handler.authorize(<auth:UserDetails>authn2, "write");
http:Forbidden? authz2 = handler.authorize(<auth:UserDetails>authn2, "update");
if (authz2 is http:Forbidden) {
test:assertFail(msg = "Test Failed!");
}
Expand All @@ -64,25 +64,25 @@ isolated function testListenerFileUserStoreBasicAuthHandlerAuthzFailure() {
auth:UserDetails|http:Unauthorized authn1 = handler.authenticate(request);
if (authn1 is auth:UserDetails) {
test:assertEquals(authn1.username, "alice");
test:assertEquals(authn1.scopes, ["read", "write"]);
test:assertEquals(authn1.scopes, ["write", "update"]);
} else {
test:assertFail(msg = "Test Failed!");
}

auth:UserDetails|http:Unauthorized authn2 = handler.authenticate(headerValue);
if (authn2 is auth:UserDetails) {
test:assertEquals(authn2.username, "alice");
test:assertEquals(authn2.scopes, ["read", "write"]);
test:assertEquals(authn2.scopes, ["write", "update"]);
} else {
test:assertFail(msg = "Test Failed!");
}

http:Forbidden? authz1 = handler.authorize(<auth:UserDetails>authn1, "update");
http:Forbidden? authz1 = handler.authorize(<auth:UserDetails>authn1, "read");
if (authz1 is ()) {
test:assertFail(msg = "Test Failed!");
}

http:Forbidden? authz2 = handler.authorize(<auth:UserDetails>authn2, "update");
http:Forbidden? authz2 = handler.authorize(<auth:UserDetails>authn2, "read");
if (authz2 is ()) {
test:assertFail(msg = "Test Failed!");
}
Expand Down
Loading