Skip to content

Commit 5e6291c

Browse files
committed
Merge branch 'development'
2 parents bd12482 + 34d4700 commit 5e6291c

File tree

12 files changed

+121
-21
lines changed

12 files changed

+121
-21
lines changed

.travis.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
language: java
2+
os: "linux"
3+
dist: focal
24

35
notifications:
46
slack:
@@ -18,16 +20,8 @@ branches:
1820
- development
1921
- master
2022

21-
dist: trusty
22-
23-
sudo: required
24-
25-
addons:
26-
apt:
27-
packages:
28-
- mysql-server-5.6
29-
- mysql-client-core-5.6
30-
- mysql-client-5.6
23+
services:
24+
- mysql
3125

3226
before_install:
3327
# CommandBox Keys
@@ -48,6 +42,10 @@ before_script:
4842
- printf "DB_DATABASE=cbsecurity\n" >> test-harness/.env
4943
- printf "DB_USER=root\n" >> test-harness/.env
5044
- printf "DB_PASSWORD=\n" >> test-harness/.env
45+
- printf "DB_BUNDLEVERSION=8.0.19\n" >> test-harness/.env
46+
- printf "DB_BUNDLENAME=com.mysql.cj\n" >> test-harness/.env
47+
# MySQL 8
48+
- printf "DB_CLASS=com.mysql.cj.jdbc.Driver\n" >> test-harness/.env
5149

5250
install:
5351
# Install Commandbox

ModuleConfig.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ component {
110110
customInterceptionPoints = [
111111
// Validator Events
112112
"cbSecurity_onInvalidAuthentication",
113-
"cbSecurity_onInvalidAuhtorization",
113+
"cbSecurity_onInvalidAuthorization",
114114
// JWT Events
115115
"cbSecurity_onJWTCreation",
116116
"cbSecurity_onJWTInvalidation",

box.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"ColdBox Security",
3-
"version":"2.8.0",
3+
"version":"2.9.0",
44
"location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbsecurity/@build.version@/[email protected]@.zip",
55
"author":"Ortus Solutions.com <[email protected]>",
66
"slug":"cbsecurity",

changelog.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
----
99

10+
## [2.9.0] => 2020-DEC-11
11+
12+
### Fixed
13+
14+
* Fixes a typo in the `cbSecurity_onInvalidAuthorization` interception point declaration. Previously, the typo would prevent ColdBox from allowing the correctly-typed interception point from ever triggering an interception listener.
15+
* The `userValidator()` method has been changed to `roleValidator()`, but the error message was forgotten! So the developer is told they need a `userValidator()` method... because the `userValidator` method is no longer supported. :/
16+
17+
### Added
18+
19+
* The `isLoggedIn()` method now makes sure that a jwt is in place and valid, before determining if you are logged in or not.
20+
* Migrated all automated tests to `focal` and `mysql8` in preparation for latest updates
21+
* Add support for JSON/XML/model rules source when loading rules from modules. Each module can now load rules not only inline but from the documented external sources.
22+
* Ensure non-configured `rules` default to empty array
23+
24+
----
25+
1026
## [2.8.0] => 2020-NOV-09
1127

1228
### Added

interceptors/Security.cfc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,20 @@ component accessors="true" extends="coldbox.system.Interceptor" {
9999
param arguments.settings.defaultAuthorizationAction = "";
100100
param arguments.settings.validator = "";
101101

102+
// Verify setting configurations
103+
variables.rulesLoader.rulesSourceChecks( arguments.settings );
104+
102105
// Store configuration in this firewall
103106
variables.securityModules[ arguments.module ] = arguments.settings;
104107

105108
// Process Module Rules
106109
arguments.settings.rules = variables.rulesLoader.normalizeRules( arguments.settings.rules, module );
107110

111+
// Load Rules if we have a ruleSource
112+
if ( arguments.settings.rulesSource.len() ) {
113+
arguments.settings.rules = variables.rulesLoader.loadRules( arguments.settings );
114+
}
115+
108116
// prepend them so the don't interfere with MAIN rules
109117
// one by one as I don't see a way to prepend the whole array at once
110118
for ( var i = arguments.settings.rules.len(); i >= 1; i-- ){
@@ -460,7 +468,7 @@ component accessors="true" extends="coldbox.system.Interceptor" {
460468
variables.validator = arguments.validator;
461469
} else {
462470
throw(
463-
message = "Validator object does not have a 'userValidator()' and `annotationValidator()' methods. I can only register objects with these interface methods.",
471+
message = "Validator object requires either a 'ruleValidator()' or `annotationValidator()' method. I can only register objects with these interface methods.",
464472
type = "Security.ValidatorMethodException"
465473
);
466474
}

models/jwt/JwtService.cfc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@ component accessors="true" singleton {
166166
* Shortcut function to our authentication services to check if we are logged in
167167
*/
168168
boolean function isLoggedIn(){
169+
// We try to authenticate because we need the JWT to be validated for the request
170+
// There are ocassions where the user could have logged out but the token is still active
171+
// Or the inverse, where there is no more token passed and user still logged in in session.
172+
try{
173+
authenticate();
174+
} catch( any e ){
175+
return false;
176+
}
177+
169178
return variables.cbSecurity.getAuthService().isLoggedIn();
170179
}
171180

models/util/RulesLoader.cfc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ component accessors="true" singleton {
6363
*/
6464
function rulesSourceChecks( required settings ){
6565
param arguments.settings.rulesSource = "";
66+
param arguments.settings.rules = [];
6667

6768
// Auto detect rules source
6869
if ( isSimpleValue( arguments.settings.rules ) ) {

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ You will receive the following data in the `interceptData` struct:
433433

434434
## Security Visualizer
435435

436-
This module also ships with a security visualizer that will document all your security rules and your settings in a nice panel. In order to activate it you must add the `enableSecurityVisualizer` setting to your config and mark it as `true`. Once enabled you can navigate to: `/cbsecurity` and you will be presentd with the visualizer.
436+
This module also ships with a security visualizer that will document all your security rules and your settings in a nice panel. In order to activate it you must add the `enableSecurityVisualizer` setting to your config and mark it as `true`. Once enabled you can navigate to: `/cbsecurity` and you will be presented with the visualizer.
437437

438438
> **Important** The visualizer is disabled by default and if it detects an environment of production, it will disable itself.
439439

test-harness/.cfconfig.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,22 @@
1818
"allowSelect":true,
1919
"allowUpdate":true,
2020
"blob":"false",
21-
"class":"com.mysql.jdbc.Driver",
2221
"clob":"false",
2322
"connectionTimeout":"1",
2423
"custom":"useUnicode=true&characterEncoding=UTF-8&useLegacyDatetimeCode=true&useSSL=false",
2524
"database":"cbsecurity",
2625
"dbdriver":"MySQL",
2726
"dsn":"jdbc:mysql://{host}:{port}/{database}",
28-
"host":"${DB_HOST}",
2927
"metaCacheTimeout":"60000",
30-
"password":"${DB_PASSWORD}",
3128
"port":"3306",
3229
"storage":"false",
30+
"validate":"false",
31+
"class":"${DB_CLASS}",
32+
"host":"${DB_HOST}",
33+
"password":"${DB_PASSWORD}",
3334
"username":"${DB_USERNAME}",
34-
"validate":"false"
35+
"bundleName": "${DB_BUNDLENAME}",
36+
"bundleVersion": "${DB_BUNDLEVERSION}"
3537
}
3638
},
3739
}

test-harness/.env

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
DB_HOST=localhost
22
DB_USERNAME=root
3-
DB_PASSWORD=mysql
3+
DB_PASSWORD=mysql
4+
5+
# MySQL 5.7
6+
#DB_CLASS=com.mysql.jdbc.Driver
7+
# MySQL 8
8+
DB_CLASS=com.mysql.cj.jdbc.Driver
9+
10+
# MySQL Lucee Bundle
11+
DB_BUNDLEVERSION=8.0.19
12+
DB_BUNDLENAME=com.mysql.cj

0 commit comments

Comments
 (0)