mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-05 05:17:54 +00:00
[WIP] feat: scoped api keys
This commit is contained in:
parent
e7ee593a85
commit
06cb160f95
45 changed files with 1264 additions and 154 deletions
|
|
@ -101,24 +101,48 @@ public class PKControllerBase: ControllerBase
|
|||
return null;
|
||||
}
|
||||
|
||||
protected bool IsAuthenticatedAs(SystemId system)
|
||||
{
|
||||
HttpContext.Items.TryGetValue("SystemId", out var systemId);
|
||||
return systemId != null && (SystemId)systemId == system;
|
||||
}
|
||||
|
||||
protected LookupContext ContextFor(PKSystem system)
|
||||
{
|
||||
HttpContext.Items.TryGetValue("SystemId", out var systemId);
|
||||
if (systemId == null) return LookupContext.ByNonOwner;
|
||||
return (SystemId)systemId == system.Id ? LookupContext.ByOwner : LookupContext.ByNonOwner;
|
||||
HttpContext.Items.TryGetValue("LookupContext", out var lookupCtx);
|
||||
if (systemId != null && (SystemId)systemId == system.Id)
|
||||
{
|
||||
if (lookupCtx != null) return (LookupContext)lookupCtx;
|
||||
return LookupContext.ByOwner;
|
||||
}
|
||||
|
||||
return LookupContext.ByNonOwner;
|
||||
}
|
||||
|
||||
protected LookupContext ContextFor(PKMember member)
|
||||
{
|
||||
HttpContext.Items.TryGetValue("SystemId", out var systemId);
|
||||
if (systemId == null) return LookupContext.ByNonOwner;
|
||||
return (SystemId)systemId == member.System ? LookupContext.ByOwner : LookupContext.ByNonOwner;
|
||||
HttpContext.Items.TryGetValue("LookupContext", out var lookupCtx);
|
||||
if (systemId != null && (SystemId)systemId == member.System)
|
||||
{
|
||||
if (lookupCtx != null) return (LookupContext)lookupCtx;
|
||||
return LookupContext.ByOwner;
|
||||
}
|
||||
|
||||
return LookupContext.ByNonOwner;
|
||||
}
|
||||
|
||||
protected LookupContext ContextFor(PKGroup group)
|
||||
{
|
||||
HttpContext.Items.TryGetValue("SystemId", out var systemId);
|
||||
if (systemId == null) return LookupContext.ByNonOwner;
|
||||
return (SystemId)systemId == group.System ? LookupContext.ByOwner : LookupContext.ByNonOwner;
|
||||
HttpContext.Items.TryGetValue("LookupContext", out var lookupCtx);
|
||||
if (systemId != null && (SystemId)systemId == group.System)
|
||||
{
|
||||
if (lookupCtx != null) return (LookupContext)lookupCtx;
|
||||
return LookupContext.ByOwner;
|
||||
}
|
||||
|
||||
return LookupContext.ByNonOwner;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue