11
11
12
12
namespace LucaDegasperi \OAuth2Server \Storage ;
13
13
14
+ use Illuminate \Contracts \Foundation \Application ;
14
15
use Illuminate \Support \ServiceProvider ;
15
16
use League \OAuth2 \Server \Storage \AccessTokenInterface ;
16
17
use League \OAuth2 \Server \Storage \AuthCodeInterface ;
@@ -43,49 +44,51 @@ public function boot()
43
44
*/
44
45
public function register ()
45
46
{
46
- $ this ->registerStorageBindings ();
47
- $ this ->registerInterfaceBindings ();
47
+ $ this ->registerStorageBindings ($ this -> app );
48
+ $ this ->registerInterfaceBindings ($ this -> app );
48
49
}
49
50
50
51
/**
51
52
* Bind the storage implementations to the IoC container.
52
53
*
54
+ * @param \Illuminate\Contracts\Foundation\Application $app
55
+ *
53
56
* @return void
54
57
*/
55
- public function registerStorageBindings ()
58
+ public function registerStorageBindings (Application $ app )
56
59
{
57
60
$ provider = $ this ;
58
61
59
- $ this -> app ->bindShared (FluentAccessToken::class, function () use ($ provider ) {
62
+ $ app ->singleton (FluentAccessToken::class, function () use ($ provider ) {
60
63
$ storage = new FluentAccessToken ($ provider ->app ['db ' ]);
61
64
$ storage ->setConnectionName ($ provider ->getConnectionName ());
62
65
63
66
return $ storage ;
64
67
});
65
68
66
- $ this -> app ->bindShared (FluentAuthCode::class, function () use ($ provider ) {
69
+ $ app ->singleton (FluentAuthCode::class, function () use ($ provider ) {
67
70
$ storage = new FluentAuthCode ($ provider ->app ['db ' ]);
68
71
$ storage ->setConnectionName ($ provider ->getConnectionName ());
69
72
70
73
return $ storage ;
71
74
});
72
75
73
- $ this -> app ->bindShared (FluentClient::class, function ($ app ) use ($ provider ) {
76
+ $ app ->singleton (FluentClient::class, function ($ app ) use ($ provider ) {
74
77
$ limitClientsToGrants = $ app ['config ' ]->get ('oauth2.limit_clients_to_grants ' );
75
78
$ storage = new FluentClient ($ provider ->app ['db ' ], $ limitClientsToGrants );
76
79
$ storage ->setConnectionName ($ provider ->getConnectionName ());
77
80
78
81
return $ storage ;
79
82
});
80
83
81
- $ this -> app ->bindShared (FluentRefreshToken::class, function () use ($ provider ) {
84
+ $ app ->singleton (FluentRefreshToken::class, function () use ($ provider ) {
82
85
$ storage = new FluentRefreshToken ($ provider ->app ['db ' ]);
83
86
$ storage ->setConnectionName ($ provider ->getConnectionName ());
84
87
85
88
return $ storage ;
86
89
});
87
90
88
- $ this -> app ->bindShared (FluentScope::class, function ($ app ) use ($ provider ) {
91
+ $ app ->singleton (FluentScope::class, function ($ app ) use ($ provider ) {
89
92
$ limitClientsToScopes = $ app ['config ' ]->get ('oauth2.limit_clients_to_scopes ' );
90
93
$ limitScopesToGrants = $ app ['config ' ]->get ('oauth2.limit_scopes_to_grants ' );
91
94
$ storage = new FluentScope ($ provider ->app ['db ' ], $ limitClientsToScopes , $ limitScopesToGrants );
@@ -94,7 +97,7 @@ public function registerStorageBindings()
94
97
return $ storage ;
95
98
});
96
99
97
- $ this -> app ->bindShared (FluentSession::class, function () use ($ provider ) {
100
+ $ app ->singleton (FluentSession::class, function () use ($ provider ) {
98
101
$ storage = new FluentSession ($ provider ->app ['db ' ]);
99
102
$ storage ->setConnectionName ($ provider ->getConnectionName ());
100
103
@@ -105,16 +108,18 @@ public function registerStorageBindings()
105
108
/**
106
109
* Bind the interfaces to their implementations.
107
110
*
111
+ * @param \Illuminate\Contracts\Foundation\Application $app
112
+ *
108
113
* @return void
109
114
*/
110
- public function registerInterfaceBindings ()
115
+ public function registerInterfaceBindings (Application $ app )
111
116
{
112
- $ this -> app ->bind (ClientInterface::class, FluentClient::class);
113
- $ this -> app ->bind (ScopeInterface::class, FluentScope::class);
114
- $ this -> app ->bind (SessionInterface::class, FluentSession::class);
115
- $ this -> app ->bind (AuthCodeInterface::class, FluentAuthCode::class);
116
- $ this -> app ->bind (AccessTokenInterface::class, FluentAccessToken::class);
117
- $ this -> app ->bind (RefreshTokenInterface::class, FluentRefreshToken::class);
117
+ $ app ->bind (ClientInterface::class, FluentClient::class);
118
+ $ app ->bind (ScopeInterface::class, FluentScope::class);
119
+ $ app ->bind (SessionInterface::class, FluentSession::class);
120
+ $ app ->bind (AuthCodeInterface::class, FluentAuthCode::class);
121
+ $ app ->bind (AccessTokenInterface::class, FluentAccessToken::class);
122
+ $ app ->bind (RefreshTokenInterface::class, FluentRefreshToken::class);
118
123
}
119
124
120
125
/**
0 commit comments