refactor(identity): change receiver of OauthUtils.ExpandScopes()
This commit is contained in:
parent
00a54f4f8b
commit
8bd118ea67
4 changed files with 13 additions and 14 deletions
|
@ -25,7 +25,7 @@ public class PasswordAuthController(ILogger logger, IdentityContext db, IClock c
|
|||
var appToken =
|
||||
HttpContext.GetToken() ??
|
||||
throw new UnreachableException(); // GetApplicationOrThrow already gets the token and throws if it's null
|
||||
var appScopes = appToken.ExpandScopes();
|
||||
var appScopes = appToken.Scopes.ExpandScopes();
|
||||
|
||||
if (req.Scopes.Except(appScopes).Any())
|
||||
throw new ApiError.Forbidden("Cannot request token scopes that are not allowed for this token",
|
||||
|
@ -54,7 +54,7 @@ public class PasswordAuthController(ILogger logger, IdentityContext db, IClock c
|
|||
{
|
||||
var app = HttpContext.GetApplicationOrThrow();
|
||||
var appToken = HttpContext.GetToken() ?? throw new UnreachableException();
|
||||
var appScopes = appToken.ExpandScopes();
|
||||
var appScopes = appToken.Scopes.ExpandScopes();
|
||||
|
||||
if (req.Scopes.Except(appScopes).Any())
|
||||
throw new ApiError.Forbidden("Cannot request token scopes that are not allowed for this token",
|
||||
|
|
|
@ -15,7 +15,7 @@ public class TokenController(ILogger logger, IdentityContext db, IClock clock) :
|
|||
public async Task<IActionResult> PostToken([FromBody] PostTokenRequest req)
|
||||
{
|
||||
var app = await db.GetApplicationAsync(req.ClientId, req.ClientSecret);
|
||||
var appScopes = app.ExpandScopes();
|
||||
var appScopes = app.Scopes.ExpandScopes();
|
||||
|
||||
var scopes = req.Scope.Split(' ');
|
||||
if (scopes.Except(appScopes).Any())
|
||||
|
@ -25,9 +25,9 @@ public class TokenController(ILogger logger, IdentityContext db, IClock clock) :
|
|||
|
||||
switch (req.GrantType)
|
||||
{
|
||||
case "client_credentials":
|
||||
case OauthUtils.ClientCredentials:
|
||||
return await HandleClientCredentialsAsync(app, scopes);
|
||||
case "authorization_code":
|
||||
case OauthUtils.AuthorizationCode:
|
||||
// TODO
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue