Skip to content

Commit

Permalink
v3.10.2 (#257)
Browse files Browse the repository at this point in the history
* Refactor - move SimpleEntity into Gameboard.Api.Features.Common.

* Don't bootstrap JobsService in integration test env

* Address an issue where Gameboard was incorrectly evaluating whether a challenge has a deployed gamespace after destroy. Resolves #182.

* Server-side hardening for illegal mime type upload. Removed bare repositories.
Updated recommended extensions.

* Add improved file upload validation. Add editor config to suppress private member warnings.

* Update unit tests

* Remove server-side html escaping of user input (handled client side).

* Resolved an issue that prevented assignees from being display in the support ticket list.

* Remove unnecessary dependency injection from the app hub.

* Fix build error in ticket service

* Update GH actions config for correct solutions file config.

* Remove unused property of game model

* Allow API key authentication to resolve grader keys as well as standard user api keys.

- Moved GetUserFromApiKey to service level
- Added tests to verify resolution of user and grader keys
- Resolved an issue where integration tests were inadvertently depending on our internal test Gamebrain instance

* set default solution path

* Additional test for grader/apikey authentication.

* Revert "Additional test for grader/apikey authentication."

This reverts commit b75727d.

* Additional test for grader api key resolution.

* Added revised grader key authentication and modified _Controller to represent an authenticated grader key separately from an authenticated user.

* Remove incorrect tests

* Set default topo timeout to 300 sec (up from 100).

* Addresses #236 along with a sister commit in GBUI.

* Remove designer from role list for admin enroll.
  • Loading branch information
sei-bstein authored Sep 12, 2023
1 parent 023a40c commit b681816
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 53 deletions.
49 changes: 1 addition & 48 deletions src/Gameboard.Api/Features/Player/PlayerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public async Task<Player> Enroll(NewPlayer model, User actor, CancellationToken
if (game.IsPracticeMode)
return await RegisterPracticeSession(model, cancellationToken);

if (!actor.IsRegistrar && !game.RegistrationActive)
if (!game.RegistrationActive && !(actor.IsRegistrar || actor.IsTester || actor.IsAdmin))
throw new RegistrationIsClosed(model.GameId);

var user = await Store.GetUserEnrollments(model.UserId);
Expand Down Expand Up @@ -273,53 +273,6 @@ public async Task<Player> StartSession(SessionStartRequest model, User actor, bo
return asViewModel;
}

// public async Task<Player> AdjustSessionEnd(SessionChangeRequest model, User actor, CancellationToken cancellationToken)
// {
// var team = await Store.ListTeam(model.TeamId).ToArrayAsync(cancellationToken);
// var sudo = actor.IsRegistrar;

// var manager = team.FirstOrDefault(p => p.Role == PlayerRole.Manager);

// if (sudo.Equals(false) && manager.IsCompetition)
// throw new ActionForbidden();

// // auto increment for practice sessions
// if (manager.IsPractice)
// {
// DateTimeOffset now = DateTimeOffset.UtcNow;
// var settings = await _practiceService.GetSettings(cancellationToken);

// // end session now or extend by one hour (hard value for now, added to practice settings later)
// model.SessionEnd = model.SessionEnd.Year == 1
// ? DateTimeOffset.UtcNow
// : DateTimeOffset.UtcNow.AddMinutes(60)
// ;
// if (settings.MaxPracticeSessionLengthMinutes.HasValue)
// {
// var maxTime = manager.SessionBegin.AddMinutes(settings.MaxPracticeSessionLengthMinutes.Value);
// if (model.SessionEnd > maxTime)
// model.SessionEnd = maxTime;
// }
// }

// foreach (var player in team)
// player.SessionEnd = model.SessionEnd;

// await Store.Update(team);

// // push gamespace extension
// var changes = await Store.DbContext.Challenges
// .Where(c => c.TeamId == manager.TeamId)
// .Select(c => GameEngine.ExtendSession(c, model.SessionEnd))
// .ToArrayAsync();

// await Task.WhenAll(changes);

// var mappedManager = Mapper.Map<Player>(manager);
// await HubBus.SendTeamUpdated(mappedManager, actor);
// return mappedManager;
// }

public async Task<Player[]> List(PlayerDataFilter model, bool sudo = false)
{
if (!sudo && !model.WantsGame && !model.WantsTeam)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Gameboard.Api.Data;
using Gameboard.Api.Features.ApiKeys;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
Expand Down Expand Up @@ -58,8 +57,8 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
new ClaimsIdentity
(
new Claim[] {
new Claim(AppConstants.SubjectClaimName, user.Id),
new Claim(AppConstants.NameClaimName, user.Name),
new(AppConstants.SubjectClaimName, user.Id),
new(AppConstants.NameClaimName, user.Name),
},
Scheme.Name
)
Expand All @@ -79,9 +78,7 @@ protected override Task HandleChallengeAsync(AuthenticationProperties properties
internal string ResolveRequestApiKey(HttpRequest request)
{
if (request.Headers.TryGetValue(ApiKeyAuthentication.ApiKeyHeaderName, out StringValues headerApiKey))
{
return headerApiKey;
}

return null;
}
Expand Down

0 comments on commit b681816

Please sign in to comment.