Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Dependency List
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
191
Issues
191
List
Boards
Labels
Service Desk
Milestones
Merge Requests
32
Merge Requests
32
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
720522f6
Commit
720522f6
authored
1 hour ago
by
Mark Harding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat): save a canary cookie to all our canaries
parent
0e644a34
master
goal/boost-campaigns-e24
No related merge requests found
Pipeline
#73954125
canceled with stages
in 14 minutes and 40 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
1 deletion
+40
-1
authenticate.php
Controllers/api/v1/authenticate.php
+5
-0
canary.php
Controllers/api/v2/canary.php
+9
-0
FeaturesProvider.php
Core/Features/FeaturesProvider.php
+3
-0
Manager.php
Core/Features/Manager.php
+23
-1
No files found.
Controllers/api/v1/authenticate.php
View file @
720522f6
...
...
@@ -10,6 +10,7 @@ namespace Minds\Controllers\api\v1;
use
Minds\Core
;
use
Minds\Core\Security
;
use
Minds\Core\Session
;
use
Minds\Core\Features
;
use
Minds\Core\Di\Di
;
use
Minds\Entities
;
use
Minds\Interfaces
;
...
...
@@ -99,6 +100,10 @@ class authenticate implements Interfaces\Api, Interfaces\ApiIgnorePam
Session
::
generateJWTCookie
(
$sessions
->
getSession
());
Security\XSRF
::
setCookie
(
true
);
// Set the canary cookie
Di
::
_
()
->
get
(
'Features\Manager'
)
->
setCanaryCookie
(
$user
->
isCanary
());
$response
[
'status'
]
=
'success'
;
$response
[
'user'
]
=
$user
->
export
();
...
...
This diff is collapsed.
Click to expand it.
Controllers/api/v2/canary.php
View file @
720522f6
...
...
@@ -23,6 +23,11 @@ class canary implements Interfaces\Api
'message'
=>
'You are not logged in'
]);
}
// Refresh the canary cookie
Di
::
_
()
->
get
(
'Features\Manager'
)
->
setCanaryCookie
(
$user
->
isCanary
());
return
Factory
::
response
([
'enabled'
=>
(
bool
)
$user
->
isCanary
(),
]);
...
...
@@ -51,6 +56,10 @@ class canary implements Interfaces\Api
],
'message'
=>
$message
,
]);
// Set the canary cookie
Di
::
_
()
->
get
(
'Features\Manager'
)
->
setCanaryCookie
(
$user
->
isCanary
());
return
Factory
::
response
([]);
}
...
...
This diff is collapsed.
Click to expand it.
Core/Features/FeaturesProvider.php
View file @
720522f6
...
...
@@ -17,5 +17,8 @@ class FeaturesProvider extends Provider
$this
->
di
->
bind
(
'Features'
,
function
(
$di
)
{
return
new
Manager
();
},
[
'useFactory'
=>
true
]);
$this
->
di
->
bind
(
'Features\Manager'
,
function
(
$di
)
{
return
new
Manager
();
},
[
'useFactory'
=>
true
]);
}
}
This diff is collapsed.
Click to expand it.
Core/Features/Manager.php
View file @
720522f6
...
...
@@ -9,6 +9,7 @@
namespace
Minds\Core\Features
;
use
Minds\Core\Di\Di
;
use
Minds\Common\Cookie
;
use
Minds\Core\Session
;
class
Manager
...
...
@@ -18,10 +19,14 @@ class Manager
/** @var Config $config */
private
$config
;
/** @var Cookie $cookie */
private
$cookie
;
public
function
__construct
(
$config
=
null
)
public
function
__construct
(
$config
=
null
,
$cookie
=
null
)
{
$this
->
config
=
$config
?:
Di
::
_
()
->
get
(
'Config'
);
$this
->
cookie
=
$cookie
?:
new
Cookie
;
}
/**
...
...
@@ -65,4 +70,21 @@ class Manager
{
return
$this
->
config
->
get
(
'features'
)
?:
[];
}
/**
* Set the canary cookie
* @param bool $enabled
* @return void
*/
public
function
setCanaryCookie
(
bool
$enabled
=
true
)
:
void
{
$this
->
cookie
->
setName
(
'canary'
)
->
setValue
((
int
)
$enabled
)
->
setExpire
(
0
)
->
setSecure
(
true
)
//only via ssl
->
setHttpOnly
(
true
)
//never by browser
->
setPath
(
'/'
)
->
create
();
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment