Skip to content

Commit

Permalink
Changed the behavior of the JWT LiveValidityWindows
Browse files Browse the repository at this point in the history
Added milligram.css to some samples
  • Loading branch information
danieleteti committed May 17, 2018
1 parent 34bc5e0 commit a4381ec
Show file tree
Hide file tree
Showing 24 changed files with 827 additions and 232 deletions.
602 changes: 602 additions & 0 deletions samples/apachemodule/Apache24/htdocs/css/milligram.css

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions samples/apachemodule/Apache24/htdocs/css/styles.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
* {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 18px;
}

.header {
padding-top: 5px;
}

#wineList {
overflow-y: scroll;
height: 80%;
}

.leftArea {
position: absolute;
left: 10px;
Expand Down
83 changes: 45 additions & 38 deletions samples/apachemodule/Apache24/htdocs/index.html
Original file line number Diff line number Diff line change
@@ -1,63 +1,70 @@
<!DOCTYPE HTML>
<html>

<head>
<title>Cellar</title>
<link rel="stylesheet" href="css/styles.css" />
<title>Cellar</title>
<link rel="stylesheet" href="css/milligram.css" />
<link rel="stylesheet" href="css/styles.css" />
</head>

<body>

<div class="header">
<input type="text" id="searchKey"/>
<button id="btnSearch">Search</button>
<button id="btnAdd">New Wine</button>
</div>
<div class="header">
<input type="text" id="searchKey" />
<button class="button" id="btnSearch">Search</button>
<button class="button" id="btnAdd">New Wine</button>
</div>


<div class="leftArea">
<ul id="wineList"></ul>
</div>
<div class="leftArea">
<ul id="wineList"></ul>
</div>

<form id="wineForm">
<form id="wineForm">

<div class="mainArea">
<div class="mainArea">

<label>Id:</label>
<input id="wineId" name="id" type="text" style="width: 50px" disabled />
<label>Id:</label>
<input id="wineId" name="id" type="text" style="width: 50px" disabled />

<label>Name:</label>
<input type="text" id="name" name="name" required>
<label>Name:</label>
<input type="text" id="name" name="name" required>

<label>Grapes:</label>
<input type="text" id="grapes" name="grapes"/>
<label>Grapes:</label>
<input type="text" id="grapes" name="grapes" />

<label>Country:</label>
<input type="text" id="country" name="country"/>
<label>Country:</label>
<input type="text" id="country" name="country" />

<label>Region:</label>
<input type="text" id="region" name="region"/>
<label>Region:</label>
<input type="text" id="region" name="region" />

<label>Year:</label>
<select id="year" name="year"><option value=""></option></select>
<div class="padding02">
<button id="btnSave">Save</button>
<button id="btnDelete">Delete</button>
</div>
</div>
<label>Year:</label>
<select id="year" name="year">
<option value=""></option>
</select>
<div class="padding02">
<button class="button" id="btnSave">Save</button>
<button class="button" id="btnDelete">Delete</button>
</div>
</div>

<div class="rightArea">
<div class="rightArea">

<img id="pic" height="300"/>
<img id="pic" height="300" />

<label>Notes:</label>
<textarea id="description" name="description"></textarea>
</div>
<label>Notes:</label>
<textarea id="description" name="description"></textarea>
</div>

</form>
</form>

<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/main.js"></script>
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/main.js"></script>

<div class="footer textcenter padding02">The client code of this demo is slightly based on <a target="_blank" href="http://coenraets.org/blog/2011/12/restful-services-with-jquery-php-and-the-slim-framework/">"RESTful services with jQuery, PHP and the Slim Framework"</a></div>
<div class="footer textcenter padding02">The client code of this demo is slightly based on
<a target="_blank" href="http://coenraets.org/blog/2011/12/restful-services-with-jquery-php-and-the-slim-framework/">"RESTful services with jQuery, PHP and the Slim Framework"</a>
</div>
</body>

</html>
3 changes: 2 additions & 1 deletion samples/apachemodule/WineCellarAppControllerU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ implementation

uses
System.SysUtils, System.Classes, System.IOUtils,
WinesBO, MVCFramework.Serializer.Commons;
WinesBO, MVCFramework.Serializer.Commons, MVCFramework.Logger;

procedure TWineCellarApp.FindWines(ctx: TWebContext);
begin
Log.Debug('','MYTAG');
Render(dm.FindWines(ctx.Request.Params['value']));
end;

Expand Down
2 changes: 1 addition & 1 deletion samples/apachemodule/mod_dmvc.dproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{61ADE231-72F2-4E11-8EDD-62C5AFEF0463}</ProjectGuid>
<ProjectVersion>18.3</ProjectVersion>
<ProjectVersion>18.4</ProjectVersion>
<FrameworkType>VCL</FrameworkType>
<MainSource>mod_dmvc.dpr</MainSource>
<Base>True</Base>
Expand Down
31 changes: 25 additions & 6 deletions samples/articles_crud_server/MainDM.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,27 @@
interface

uses
System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option,
FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.FB, Data.DB,
FireDAC.Comp.Client, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf,
FireDAC.DApt, FireDAC.Comp.DataSet, FireDAC.Phys.FBDef, FireDAC.VCLUI.Wait;
System.SysUtils,
System.Classes,
FireDAC.Stan.Intf,
FireDAC.Stan.Option,
FireDAC.Stan.Error,
FireDAC.UI.Intf,
FireDAC.Phys.Intf,
FireDAC.Stan.Def,
FireDAC.Stan.Pool,
FireDAC.Stan.Async,
FireDAC.Phys,
FireDAC.Phys.FB,
Data.DB,
FireDAC.Comp.Client,
FireDAC.Stan.Param,
FireDAC.DatS,
FireDAC.DApt.Intf,
FireDAC.DApt,
FireDAC.Comp.DataSet,
FireDAC.Phys.FBDef,
FireDAC.VCLUI.Wait;

type
TdmMain = class(TDataModule)
Expand All @@ -28,10 +44,13 @@ implementation

procedure TdmMain.ConnectionBeforeConnect(Sender: TObject);
begin
// currently, this demo uses firebird 2.5
{$IFNDEF WINDOWSSERVICE}
// if you want to use firebird 2.5, you can use the file ORDERSMANAGER_FB25.FDB
Connection.Params.Values['Database'] := '..\..\data\ORDERSMANAGER_FB30.FDB';
// Connection.Params.Values['Database'] := '..\..\data\ORDERSMANAGER_FB25.FDB';
{$ELSE}
Connection.Params.Values['Database'] := 'C:\DEV\dmvcframework\samples\data\ORDERSMANAGER_FB30.FDB';
{$ENDIF}
end;

end.
1 change: 0 additions & 1 deletion samples/articles_crud_server/WebModuleUnit1.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ object WebModule1: TWebModule1
Default = True
Name = 'DefaultHandler'
PathInfo = '/'
OnAction = WebModule1DefaultHandlerAction
end>
Height = 230
Width = 415
Expand Down
14 changes: 1 addition & 13 deletions samples/articles_crud_server/WebModuleUnit1.pas
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ interface

type
TWebModule1 = class(TWebModule)
procedure WebModule1DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
procedure WebModuleCreate(Sender: TObject);
private
FEngine: TMVCEngine;
Expand All @@ -26,22 +24,12 @@ implementation

{$R *.dfm}

procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
Response.Content :=
'<html>' +
'<head><title>Web Server Application</title></head>' +
'<body>Web Server Application</body>' +
'</html>';
end;

procedure TWebModule1.WebModuleCreate(Sender: TObject);
begin
FEngine := TMVCEngine.Create(self);
FEngine.AddController(TArticlesController);
FEngine.AddMiddleware(TCORSMiddleware.Create);
FEngine.AddMiddleware(TCompressionMiddleware.Create);
FEngine.AddMiddleware(TCompressionMiddleware.Create(256));

end;

Expand Down
1 change: 0 additions & 1 deletion samples/jsonwebtoken/vclclient/MainClientFormU.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ object Form5: TForm5
Caption = 'Get a protected resource'
TabOrder = 0
OnClick = btnGetClick
ExplicitTop = 2
end
object btnLOGIN: TButton
AlignWithMargins = True
Expand Down
2 changes: 1 addition & 1 deletion samples/jsonwebtoken_livevaliditywindow/JWTServer.dproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{7B54055A-5749-4136-9FE2-35FDBEEA874C}</ProjectGuid>
<ProjectVersion>18.2</ProjectVersion>
<ProjectVersion>18.4</ProjectVersion>
<FrameworkType>VCL</FrameworkType>
<MainSource>JWTServer.dpr</MainSource>
<Base>True</Base>
Expand Down
18 changes: 5 additions & 13 deletions samples/jsonwebtoken_livevaliditywindow/WebModuleUnit1.pas
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ implementation

{$R *.dfm}


uses
AppControllerU,
System.Generics.Collections,
Expand All @@ -45,29 +44,22 @@ procedure TWebModule1.WebModuleCreate(Sender: TObject);
JWT.Claims.Issuer := 'Delphi MVC Framework JWT Middleware Sample';
JWT.Claims.NotBefore := Now - OneMinute * 5; // valid since 5 minutes ago
JWT.Claims.IssuedAt := Now;
JWT.Claims.ExpirationTime := Now + OneSecond * 30;
JWT.CustomClaims['mycustomvalue'] := 'hello there';
// Here we dont use a fixed ExpirationTime but a LiveValidityWindowInSeconds
// to make the ExpirationTime dynamic, incrementing the
// ExpirationTime by LiveValidityWindowInSeconds seconds at each request
JWT.LiveValidityWindowInSeconds := 5; // 60 * 60; // 1 hour
JWT.LiveValidityWindowInSeconds := 10; // 60 * 60; // 1 hour
end;

MVC := TMVCEngine.Create(Self);
MVC.Config[TMVCConfigKey.DocumentRoot] := '..\..\www';
MVC.Config[TMVCConfigKey.SessionTimeout] := '30';
MVC.Config[TMVCConfigKey.DefaultContentType] := 'text/html';
MVC.AddController(TApp1MainController).AddController(TAdminController)
.AddMiddleware(TMVCJWTAuthenticationMiddleware.Create(
TAuthenticationSample.Create,
lClaimsSetup,
'mys3cr37',
'/login',
[
TJWTCheckableClaim.ExpirationTime,
TJWTCheckableClaim.NotBefore,
TJWTCheckableClaim.IssuedAt
],
0 // just for test, Leeway seconds is zero.
.AddMiddleware(TMVCJWTAuthenticationMiddleware.Create(TAuthenticationSample.Create, lClaimsSetup, 'mys3cr37',
'/login', [TJWTCheckableClaim.ExpirationTime, TJWTCheckableClaim.NotBefore, TJWTCheckableClaim.IssuedAt], 0
// just for test, Leeway seconds is zero.
));
end;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{E7317702-64D3-4A65-8734-030F3AE3DBBC}</ProjectGuid>
<ProjectVersion>18.2</ProjectVersion>
<ProjectVersion>18.4</ProjectVersion>
<FrameworkType>VCL</FrameworkType>
<MainSource>JWTClient.dpr</MainSource>
<Base>True</Base>
Expand Down
2 changes: 1 addition & 1 deletion samples/middleware/MiddlewareSamples.dproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{0388D146-2B8B-427B-AEDD-EFD5F51D3139}</ProjectGuid>
<ProjectVersion>18.2</ProjectVersion>
<ProjectVersion>18.4</ProjectVersion>
<FrameworkType>VCL</FrameworkType>
<MainSource>MiddlewareSamples.dpr</MainSource>
<Base>True</Base>
Expand Down
16 changes: 2 additions & 14 deletions samples/outputcachewithredis/OutputCacheWithRedis.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ program OutputCacheWithRedis;

uses
System.SysUtils,
Winapi.Windows,
IdHTTPWebBrokerBridge,
Web.WebReq,
Web.WebBroker,
Expand All @@ -20,9 +19,6 @@ uses

procedure RunServer(APort: Integer);
var
LInputRecord: TInputRecord;
LEvent: DWord;
LHandle: THandle;
LServer: TIdHTTPWebBrokerBridge;
begin
Writeln(Format('Starting "OutputCacheWithRedis" HTTP Server or port %d', [APort]));
Expand All @@ -32,16 +28,8 @@ begin
LServer.ListenQueue := 200;
LServer.MaxConnections := 5000;
LServer.Active := True;
Writeln('Press ESC to stop the server');
LHandle := GetStdHandle(STD_INPUT_HANDLE);
while True do
begin
Win32Check(ReadConsoleInput(LHandle, LInputRecord, 1, LEvent));
if (LInputRecord.EventType = KEY_EVENT) and
LInputRecord.Event.KeyEvent.bKeyDown and
(LInputRecord.Event.KeyEvent.wVirtualKeyCode = VK_ESCAPE) then
break;
end;
Writeln('Press RETURN to stop the server');
ReadLn;
finally
LServer.Free;
end;
Expand Down
2 changes: 1 addition & 1 deletion samples/outputcachewithredis/OutputCacheWithRedis.dproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{BE3A3D14-17E0-45C1-BD21-4710DE4CBCC2}</ProjectGuid>
<ProjectVersion>18.2</ProjectVersion>
<ProjectVersion>18.4</ProjectVersion>
<FrameworkType>VCL</FrameworkType>
<MainSource>OutputCacheWithRedis.dpr</MainSource>
<Base>True</Base>
Expand Down
2 changes: 0 additions & 2 deletions samples/renders/MyDataModuleU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ TMyDataModule = class(TDataModule)
{ Public declarations }
end;

var
MyDataModule: TMyDataModule;

implementation

Expand Down
2 changes: 1 addition & 1 deletion samples/renders/RenderSampleControllerU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ procedure TRenderSampleController.GetCustomers_AsDataSet(CTX: TWebContext);
lDM := TMyDataModule.Create(nil);
try
lDM.qryCustomers.Open;
Render(lDM.qryCustomers);
Render(lDM.qryCustomers, False);
finally
lDM.Free;
end;
Expand Down
Loading

0 comments on commit a4381ec

Please sign in to comment.