@@ -17,21 +17,12 @@ component accessors="true" singleton {
17
17
property name = " interceptorService" inject = " coldbox:interceptorService" ;
18
18
property name = " requestService" inject = " coldbox:requestService" ;
19
19
property name = " log" inject = " logbox:logger:{this}" ;
20
+ property name = " cbsecurity" inject = " @cbSecurity" ;
20
21
21
22
/* ********************************************************************************************/
22
23
/* * PROPERTIES **/
23
24
/* ********************************************************************************************/
24
25
25
- /**
26
- * The auth service in use
27
- */
28
- property name = " authService" ;
29
-
30
- /**
31
- * The user service in use
32
- */
33
- property name = " userService" ;
34
-
35
26
/**
36
27
* The token storage provider
37
28
*/
@@ -145,7 +136,7 @@ component accessors="true" singleton {
145
136
required password ,
146
137
struct customClaims = {}
147
138
){
148
- var auth = getAuthService ();
139
+ var auth = cbSecurity . getAuthService ();
149
140
150
141
if ( auth .authenticate ( arguments .username , arguments .password ) ) {
151
142
// Create it
@@ -164,14 +155,14 @@ component accessors="true" singleton {
164
155
*/
165
156
function logout (){
166
157
invalidate ( this .getToken () );
167
- getAuthService ().logout ();
158
+ cbSecurity . getAuthService ().logout ();
168
159
}
169
160
170
161
/**
171
162
* Shortcut function to our authentication services to check if we are logged in
172
163
*/
173
164
boolean function isLoggedIn (){
174
- return getAuthService ().isLoggedIn ();
165
+ return cbSecurity . getAuthService ().isLoggedIn ();
175
166
}
176
167
177
168
/**
@@ -253,7 +244,7 @@ component accessors="true" singleton {
253
244
*/
254
245
function authenticate (){
255
246
// Get the User it represents
256
- var oUser = getUserService ().retrieveUserById ( getPayload ().sub );
247
+ var oUser = variables . cbSecurity . getUserService ().retrieveUserById ( getPayload ().sub );
257
248
258
249
// Verify it
259
250
if ( isNull ( oUser ) || ! len ( oUser .getId () ) ) {
@@ -273,7 +264,7 @@ component accessors="true" singleton {
273
264
}
274
265
275
266
// Log in the user
276
- getAuthService ().login ( oUser );
267
+ variables . cbSecurity . getAuthService ().login ( oUser );
277
268
278
269
// Store in ColdBox data bus
279
270
variables .requestService
@@ -669,50 +660,6 @@ component accessors="true" singleton {
669
660
return variables .tokenStorage ;
670
661
}
671
662
672
- /**
673
- * Get the user service defined in the settings
674
- */
675
- any function getUserService (){
676
- // If loaded, use it!
677
- if ( ! isNull ( variables .userService ) ) {
678
- return variables .userService ;
679
- }
680
-
681
- // Check and Load Baby!
682
- if ( ! len ( variables .settings .userService ) ) {
683
- throw (
684
- message = " No [userService] provided in the settings. Please set in `config/ColdBox.cfc` under `moduleSettings.cbsecurity.userService`." ,
685
- type = " IncompleteConfiguration"
686
- );
687
- }
688
-
689
- variables .userService = variables .wirebox .getInstance ( variables .settings .userService );
690
-
691
- return variables .userService ;
692
- }
693
-
694
- /**
695
- * Get the authentication service defined in the settings
696
- */
697
- any function getAuthService (){
698
- // If loaded, use it!
699
- if ( ! isNull ( variables .authService ) ) {
700
- return variables .authService ;
701
- }
702
-
703
- // Check and Load Baby!
704
- if ( ! len ( variables .settings .authenticationService ) ) {
705
- throw (
706
- message = " No [authService] provided in the settings. Please set in `config/ColdBox.cfc` under `moduleSettings.cbsecurity.authenticationService`." ,
707
- type = " IncompleteConfiguration"
708
- );
709
- }
710
-
711
- variables .authService = variables .wirebox .getInstance ( variables .settings .authenticationService );
712
-
713
- return variables .authService ;
714
- }
715
-
716
663
/* ***************************** PRIVATE ******************************/
717
664
718
665
/**
@@ -761,14 +708,14 @@ component accessors="true" singleton {
761
708
}
762
709
763
710
// Are we logged in?
764
- if ( getAuthService ().isLoggedIn () ) {
711
+ if ( variables . cbSecurity . getAuthService ().isLoggedIn () ) {
765
712
// Do we have any permissions to validate?
766
713
if ( listLen ( arguments .permissions ) ) {
767
714
// Check if the user has the right permissions?
768
715
results .allow = (
769
716
tokenHasScopes ( arguments .permissions , payload .scopes )
770
717
||
771
- getAuthService ().getUser ().hasPermission ( arguments .permissions )
718
+ variables . cbSecurity . getAuthService ().getUser ().hasPermission ( arguments .permissions )
772
719
);
773
720
results .type = " authorization" ;
774
721
} else {
0 commit comments