In my Sphinx server, I do the following:
procedure TfrmMain.SphinxConfigConfigureToken(Sender: TObject; Args: TConfigureTokenArgs);
begin
Args.Token.Claims.AddOrSet('user_role', 'user');
if SameText(Args.User.UserName.Value, 'mark') then
Args.Token.Claims.AddOrSet('user_role', 'admin');
end;
I have three entity types with the following (partial) implementation for my XData server:
[Entity]
[EntityAuthorizeClaims('user_role', 'user', EntitySetPermissionsAll)]
[EntityAuthorizeClaims('user_role', 'admin', EntitySetPermissionsAll)]
[Table('Invoice')]
[Id('FID', TIdGenerator.Guid)]
TInvoice = class
private
[Column('ID', [TColumnProp.Required])]
FID: TGuid;
.........
[Entity]
[EntityAuthorizeClaims('user_role', 'user', EntitySetPermissionsRead)]
[EntityAuthorizeClaims('user_role', 'admin', EntitySetPermissionsAll)]
[Table('InvoiceItem')]
[Id('FID', TIdGenerator.Guid)]
TInvoiceItem = class
private
[Column('ID', [TColumnProp.Required])]
FID: TGuid;
......
[Entity]
[Table('Secret')]
[EntityAuthorizeClaims('user_role', 'user', EntitySetPermissionsNone)]
[EntityAuthorizeClaims('user_role', 'admin', EntitySetPermissionsAll)]
[Id('FID', TIdGenerator.Guid)]
TSecret = class
private
[Column('ID', [TColumnProp.Required])]
FID: TGuid;
...............
Logging in as user 'mark' (user_role = admin) I do not have access (in the XData server) to the TInvoice and TInvoiceItem entities (403) but I do have access to the TSecret entities. Logging in as any other user (user_role = user) I don't have access to any entity.
What am I misunderstanding/doing wrong?
Adding/setting a claim 'scope' with a value 'user' or 'user admin' in combination with EntityAuthorizeScopes worked fine. Is my understanding correct that this scope is not related to the scope of the ClientApp in Sphinx?