Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@
return new CatalogueModel({ nodeId: 0 });
},
resourceDescription(): string {
return this.resourceDetails.description;
return this.resourceDetails.description;
},
isDividerVisible(): boolean {
return this.resourceDetails.resourceCatalogueId >= 0 && this.selectionInProgress;
},
allowCatalogueChange(): boolean {
return (!Boolean(this.$route.query.initialCreate)); // allow if user is contributing into the catalogue root // or if the user is editing an existing draft (initialCreate=false)
//this.resourceDetails.resourceCatalogueId === this.resourceDetails.nodeId) ||
return (this.resourceDetails.resourceCatalogueId === this.resourceDetails.nodeId) || // allow if user is contributing into the catalogue root
!Boolean(this.$route.query.initialCreate);
// allow if user is contributing into the catalogue root // or if the user is editing an existing draft (initialCreate=false)
},
onChangeClick() {
this.$emit('change-click');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
</div>
</div>

<catalogue-select v-if="resourceCatalogueCount>1 && showCatalogueSelect" v-model.number="resourceCatalogueId" @input="catalogueSelected"></catalogue-select>
<catalogue-select v-if="resourceCatalogueCount>0 && showCatalogueSelect" v-model.number="resourceCatalogueId" @input="catalogueSelected"></catalogue-select>
</div>
</template>

Expand Down Expand Up @@ -314,11 +314,11 @@
return this.$store.state.userProviders;
},
resourceCatalogueCount(): number {
if (!this.$store.state.userCatalogues) {
if (!this.$store.state.userCatalogues) {
return 0;
} else {
return this.$store.state.userCatalogues.length;
}
}
},
userIsAuthor(): boolean {
return this.authors.filter(a => a.isContributor).length > 0;
Expand All @@ -333,9 +333,8 @@
return this.$store.state.resourceDetail.resourceType;
},
showCatalogueSelect(): boolean {
//return (this.resourceDetail.resourceCatalogueId === this.resourceDetail.nodeId) || // show if user is contributing into the catalogue root
// !Boolean(this.$route.query.initialCreate); // or if the user is editing an existing draft (initialCreate=false)
return (!Boolean(this.$route.query.initialCreate));
return (this.resourceDetail.resourceCatalogueId === this.resourceDetail.nodeId) || // show if user is contributing into the catalogue root
!Boolean(this.$route.query.initialCreate); // or if the user is editing an existing draft (initialCreate=false)
},
newKeywordTrimmed(): string {
return this.newKeyword?.trim().replace(/ +(?= )/g, '');
Expand Down
2 changes: 1 addition & 1 deletion LearningHub.Nhs.WebUI/Styles/nhsuk/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ button[data-toggle="modal"] {
}

.autosuggestion-menu {
padding: 16px 16px 0px 16px;
padding: 16px 16px 0px 16px !important;
background-color: $color_nhsuk-white;
border-bottom: 1px solid $color_nhsuk-grey-4;
border-radius: 0px 0px 4px 4px;
Expand Down
17 changes: 8 additions & 9 deletions LearningHub.Nhs.WebUI/Views/Catalogue/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
ViewData["Title"] = "Catalogue";


bool CanManage()
{
return IsInRole(RoleEnum.LocalAdmin);
}
bool CanManage()
{
return IsInRole(RoleEnum.LocalAdmin);
}

bool Unlocked()
{
return IsInRole(RoleEnum.LocalAdmin) || IsInRole(RoleEnum.Editor) || IsInRole(RoleEnum.Reader) ;
//// || this.User.IsInRole("Administrator")
}
bool Unlocked()
{
return IsInRole(RoleEnum.LocalAdmin) || IsInRole(RoleEnum.Editor) || IsInRole(RoleEnum.Reader) || this.User.IsInRole("Administrator");
}

bool IsInRole(RoleEnum role)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
using System.Threading.Tasks;
using LearningHub.Nhs.Models.Bookmark;
using LearningHub.Nhs.OpenApi.Services.Interface.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

/// <summary>
/// Learning Hub Bookmark controller.
/// </summary>
[Route("Bookmark")]
[ApiController]
[Authorize]
public class BookmarkController : OpenApiControllerBase
{
private readonly IBookmarkService bookmarkService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/// </summary>
[Route("Catalogue")]
[Authorize]
[ApiController]
public class CatalogueController : OpenApiControllerBase
{
private readonly ICatalogueService catalogueService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace LearningHub.NHS.OpenAPI.Controllers
/// </summary>
[Route("Resource")]
[Authorize]
[ApiController]
public class ResourceController : OpenApiControllerBase
{
private const int MaxNumberOfReferenceIds = 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
using LearningHub.Nhs.OpenApi.Models.Configuration;
using LearningHub.Nhs.OpenApi.Repositories.Interface.Repositories;
using LearningHub.Nhs.OpenApi.Services.Interface.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

/// <summary>
/// Search operations.
/// </summary>
[Authorize]
[Route("Search")]
[ApiController]
public class SearchController : OpenApiControllerBase
Expand Down
18 changes: 10 additions & 8 deletions OpenAPI/LearningHub.Nhs.OpenApi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,29 @@ namespace LearningHub.NHS.OpenAPI
using System.Collections.Generic;
using System.IO;
using AspNetCore.Authentication.ApiKey;
using LearningHub.Nhs.Api.Authentication;
using LearningHub.Nhs.Caching;
using LearningHub.Nhs.Models.Enums;
using LearningHub.Nhs.Models.Extensions;
using LearningHub.NHS.OpenAPI.Auth;
using LearningHub.NHS.OpenAPI.Authentication;
using LearningHub.NHS.OpenAPI.Configuration;
using LearningHub.NHS.OpenAPI.Middleware;
using LearningHub.Nhs.OpenApi.Repositories;
using LearningHub.Nhs.OpenApi.Repositories.EntityFramework;
using LearningHub.Nhs.OpenApi.Services;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using Microsoft.AspNetCore.Authorization;
using LearningHub.NHS.OpenAPI.Authentication;
using LearningHub.Nhs.Api.Authentication;

/// <summary>
/// The Startup class.
Expand Down Expand Up @@ -62,8 +61,12 @@ public void ConfigureServices(IServiceCollection services)

services.AddApiKeyAuth();

services.AddAuthentication()
.AddJwtBearer(options =>
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.Authority = this.Configuration.GetValue<string>("LearningHUbAuthServiceConfig:Authority");
options.TokenValidationParameters = new TokenValidationParameters()
Expand All @@ -76,7 +79,7 @@ public void ConfigureServices(IServiceCollection services)
});

services.AddCustomMiddleware();
services.AddSingleton<IAuthorizationHandler, ReadWriteHandler>();
services.AddSingleton<IAuthorizationHandler, ReadWriteHandler>();
services.AddSingleton<IAuthorizationHandler, AuthorizeOrCallFromLHHandler>();

services.AddRepositories(this.Configuration);
Expand All @@ -89,7 +92,6 @@ public void ConfigureServices(IServiceCollection services)
services.AddControllers(options =>
{
options.Filters.Add(new HttpResponseExceptionFilter());
options.Filters.Add(new AuthorizeFilter());
});

services.AddMvc()
Expand Down
1 change: 1 addition & 0 deletions OpenAPI/LearningHub.Nhs.OpenApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"UseRedisCache": true,
"ResourcePublishQueueRouteName": "",
"HierarchyEditPublishQueueName": "",
"ContentManagementQueueName": "",
"AuthClientIdentityKey": "",
"LHClientIdentityKey": "",
"ReportApiClientIdentityKey": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ BEGIN
,cnv.CardImageUrl
,cnv.Url
,cnv.RestrictedAccess
,CAST(CASE WHEN cnv.RestrictedAccess = 1 THEN 0 ELSE 1 END AS bit) AS HasAccess
,CAST(CASE WHEN cnv.RestrictedAccess = 1 AND auth.CatalogueNodeId IS NULL THEN 0 ELSE 1 END AS bit) AS HasAccess
,ub.Id AS BookMarkId
,CAST(ISNULL(ub.[Deleted], 1) ^ 1 AS BIT) AS IsBookmarked
FROM @MyActivity ma
Expand Down
Loading