Skip to content

Commit

Permalink
renamed TAuthGroup.SqlAccessRights as OrmAccessRights
Browse files Browse the repository at this point in the history
- for consistency with mORMot 2 naming
  • Loading branch information
Arnaud Bouchez committed Sep 15, 2023
1 parent bfe706f commit 73814df
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/mormot.commit.inc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
'2.1.5875'
'2.1.5876'
21 changes: 17 additions & 4 deletions src/rest/mormot.rest.core.pas
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,21 @@ TAuthGroup = class(TOrm)
// - content is converted into/from text format via AccessRight DB property
// (so it will be not fixed e.g. by the binary TOrmTableBits layout, i.e.
// the MAX_TABLES constant value)
// - if you want to call Edit on the returned value, use a temp variable:
// !var
// ! oar: TOrmAccessRights;
// !begin
// ! oar := Group.OrmAccessRights;
// ! oar.Edit(....);
// ! oar.Edit(....);
// ! Group.OrmAccessRights := oar;
// ! rest.Update(Group);
property OrmAccessRights: TOrmAccessRights
read GetOrmAccessRights write SetOrmAccessRights;
{$ifndef PUREMORMOT2}
property SqlAccessRights: TOrmAccessRights
read GetOrmAccessRights write SetOrmAccessRights;
{$endif PUREMORMOT2}
published
/// the access right identifier, ready to be displayed
// - the same identifier can be used only once (this column is marked as
Expand Down Expand Up @@ -3548,29 +3561,29 @@ class procedure TAuthGroup.InitializeTable(const Server: IRestOrmServer;
// Guest No No No No No Yes No
A := FULL_ACCESS_RIGHTS;
G.Ident := 'Admin';
G.SqlAccessRights := A;
G.OrmAccessRights := A;
G.SessionTimeout := AuthAdminGroupDefaultTimeout;
AdminID := Server.Add(G, true);
G.Ident := 'Supervisor';
A.AllowRemoteExecute := SUPERVISOR_ACCESS_RIGHTS.AllowRemoteExecute;
A.Edit(AuthUserIndex, [ooSelect]); // AuthUser R/O
A.Edit(AuthGroupIndex, [ooSelect]); // AuthGroup R/O
G.SqlAccessRights := A;
G.OrmAccessRights := A;
G.SessionTimeout := AuthSupervisorGroupDefaultTimeout;
SupervisorID := Server.Add(G, true);
G.Ident := 'User';
Exclude(A.AllowRemoteExecute, reSqlSelectWithoutTable);
Exclude(A.GET, AuthUserIndex); // no Auth R
Exclude(A.GET, AuthGroupIndex);
G.SqlAccessRights := A;
G.OrmAccessRights := A;
G.SessionTimeout := AuthUserGroupDefaultTimeout;
UserID := Server.Add(G, true);
G.Ident := 'Guest';
A.AllowRemoteExecute := [];
FillcharFast(A.POST, SizeOf(TOrmTableBits), 0); // R/O access
FillcharFast(A.PUT, SizeOf(TOrmTableBits), 0);
FillcharFast(A.DELETE, SizeOf(TOrmTableBits), 0);
G.SqlAccessRights := A;
G.OrmAccessRights := A;
G.SessionTimeout := AuthGuestGroupDefaultTimeout;
Server.Add(G, true);
finally
Expand Down
4 changes: 2 additions & 2 deletions src/rest/mormot.rest.server.pas
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ TAuthSession = class(TAuthSessionParent)
property TimeOutTix: cardinal
read fTimeOutTix;
/// copy of the associated user access rights
// - extracted from User.TAuthGroup.SqlAccessRights
// - extracted from User.TAuthGroup.OrmAccessRights
property AccessRights: TOrmAccessRights
read fAccessRights;
/// the hexadecimal private key as returned to the connected client
Expand Down Expand Up @@ -4686,7 +4686,7 @@ procedure TAuthSession.ComputeProtectedValues(tix: Int64);
// here User.GroupRights and fPrivateKey should have been set
fTimeOutShr10 := (QWord(User.GroupRights.SessionTimeout) * (1000 * 60)) shr 10;
fTimeOutTix := tix shr 10 + fTimeOutShr10;
fAccessRights := User.GroupRights.SqlAccessRights;
fAccessRights := User.GroupRights.OrmAccessRights;
FormatUtf8('%+%', [fID, fPrivateKey], fPrivateSalt);
fPrivateSaltHash := crc32(crc32(0, pointer(fPrivateSalt), length(fPrivateSalt)),
pointer(User.PasswordHashHexa), length(User.PasswordHashHexa));
Expand Down

0 comments on commit 73814df

Please sign in to comment.