-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from MasoniteFramework/develop
Masonite 1.4
- Loading branch information
Showing
12 changed files
with
139 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
''' Welcome The User To Masonite ''' | ||
|
||
from masonite.request import Request | ||
|
||
class WelcomeController(object): | ||
class WelcomeController: | ||
''' Controller For Welcoming The User ''' | ||
|
||
def show(self, Application, request: Request): | ||
def show(self, Application): | ||
''' Show Welcome Template ''' | ||
return view('welcome', {'app': Application}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
''' CSRF Middleware ''' | ||
|
||
from masonite.exceptions import InvalidCSRFToken | ||
|
||
|
||
class CsrfMiddleware: | ||
''' Verify CSRF Token Middleware ''' | ||
|
||
exempt = [] | ||
|
||
def __init__(self, Request, Csrf, ViewClass): | ||
self.request = Request | ||
self.csrf = Csrf | ||
self.view = ViewClass | ||
|
||
def before(self): | ||
token = self.__verify_csrf_token() | ||
|
||
self.view.share({ | ||
'csrf_field': "<input type='hidden' name='csrf_token' value='{0}' />".format(token) | ||
}) | ||
|
||
def after(self): | ||
pass | ||
|
||
def __in_exempt(self): | ||
""" | ||
Determine if the request has a URI that should pass | ||
through CSRF verification. | ||
""" | ||
|
||
if self.request.path in self.exempt: | ||
return True | ||
else: | ||
return False | ||
|
||
def __verify_csrf_token(self): | ||
""" | ||
Verify si csrf token in post is valid. | ||
""" | ||
|
||
if self.request.is_post() and not self.__in_exempt(): | ||
token = self.request.input('csrf_token') | ||
if not self.csrf.verify_csrf_token(token): | ||
raise InvalidCSRFToken("Invalid CSRF token.") | ||
else: | ||
token = self.csrf.generate_csrf_token() | ||
|
||
return token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
''' Broadcast Settings ''' | ||
|
||
import os | ||
|
||
''' | ||
|-------------------------------------------------------------------------- | ||
| Broadcast Driver | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Realtime support is critical for any modern web application. Broadcast | ||
| drivers allow you to push data from your server to all your clients | ||
| to show data updates to your clients in real time without having | ||
| to constantly refresh the page or send constant ajax requests | ||
| | ||
| Supported: 'pusher', 'ably' | ||
| | ||
''' | ||
|
||
DRIVER = os.getenv('BROADCAST_DRIVER', 'pusher') | ||
|
||
''' | ||
|-------------------------------------------------------------------------- | ||
| Broadcast Drivers | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Below is a dictionary of all your driver configurations. Each key in the | ||
| dictionary should be the name of a driver. | ||
| | ||
''' | ||
|
||
DRIVERS = { | ||
'pusher': { | ||
'app_id': os.getenv('PUSHER_APP_ID', '29382xx..'), | ||
'client': os.getenv('PUSHER_CLIENT', 'shS8dxx..'), | ||
'secret': os.getenv('PUSHER_SECRET', 'HDGdjss..'), | ||
}, | ||
'ably': { | ||
'secret': os.getenv('ABLY_SECRET', 'api:key') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
''' Cache Settings ''' | ||
|
||
''' | ||
|-------------------------------------------------------------------------- | ||
| Cache Driver | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Caching is a great way to gain an instant speed boost to your application. | ||
| Very often templates will not change and you can utilize caching to the | ||
| best by caching your templates forever, monthly or every few seconds | ||
| | ||
| Supported: 'disk' | ||
| | ||
''' | ||
|
||
DRIVER = 'disk' | ||
|
||
''' | ||
|-------------------------------------------------------------------------- | ||
| Cache Drivers | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Place all your caching coniguration as a dictionary here. The keys here | ||
| should correspond to the driver types supported above. | ||
| | ||
''' | ||
|
||
DRIVERS = { | ||
'disk': { | ||
'location': 'bootstrap/cache' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters