#1 2014-07-13 04:06:32

avista
Member
Registered: 2014-01-06
Posts: 63

How do I safely manage TSQLAuthGroup records at runtime

I'm using Interface Based Services in sicPerThread mode.

When my TSQLRestServerFullMemory service starts I want to be able to add additional TSQLAuthGroup records and/or modify the access rights.  I also want to dynamically add/update/delete entries in this table at runtime.

I've overridden TSQLRestServerAuthenticationNone to support custom TSQLAuthUser creation via the GetUser() method, which works fine for external database user management.  However, I want to use the existing TSQLAuthGroup functionality in mORMot.

My question is what is the best way to manage the AuthGroups table?  I tried overriding the TSQLAuthGroup.InitializeTable() class method to populate the table at startup, but it doesn't get called because the TSQLAuthGroup and TSQLAuthUser classes are set early during service creation (so I can't create my own entries there).

I assume it's just a simple matter of having a routine that deletes existing records and adds new ones as needed at startup?  Also, when the service is running, I'm assuming that any calls to update these tables (e.g. periodically calling a method to do this like MyRestServer.UpdateAuthGroups() from an external thread) will be thread-safe.  Or is there something additional I need to do to ensure thread-safety during runtime?

Thanks

Last edited by avista (2014-07-13 04:08:06)

Offline

#2 2014-07-13 10:44:07

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: How do I safely manage TSQLAuthGroup records at runtime

The DB layer access is thread-safe:there is a global lock for each table storage.
E.g. for TSQLRestServerFullMemory , it is via TSQLRestStorage.StorageLock()/StorageUnlock() calls.

So you can change the tables safely, from any thread.

Offline

Board footer

Powered by FluxBB