diff --git a/src/Squidex.Infrastructure/Security/Extensions.cs b/src/Squidex.Infrastructure/Security/Extensions.cs new file mode 100644 index 000000000..a4025bae1 --- /dev/null +++ b/src/Squidex.Infrastructure/Security/Extensions.cs @@ -0,0 +1,41 @@ +// ========================================================================== +// Extensions.cs +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex Group +// All rights reserved. +// ========================================================================== + +using System.Linq; +using System.Security.Claims; + +namespace Squidex.Infrastructure.Security +{ + public static class Extensions + { + public static string OpenIdSubject(this ClaimsPrincipal principal) + { + return principal.Claims.FirstOrDefault(x => x.Type == OpenIdClaims.Subject)?.Value; + } + + public static string OpenIdPreferredUserName(this ClaimsPrincipal principal) + { + return principal.Claims.FirstOrDefault(x => x.Type == OpenIdClaims.PreferredUserName)?.Value; + } + + public static string OpenIdName(this ClaimsPrincipal principal) + { + return principal.Claims.FirstOrDefault(x => x.Type == OpenIdClaims.Name)?.Value; + } + + public static string OpenIdNickName(this ClaimsPrincipal principal) + { + return principal.Claims.FirstOrDefault(x => x.Type == OpenIdClaims.NickName)?.Value; + } + + public static string OpenIdEmail(this ClaimsPrincipal principal) + { + return principal.Claims.FirstOrDefault(x => x.Type == OpenIdClaims.Email)?.Value; + } + } +} diff --git a/src/Squidex.Infrastructure/Security/OpenIdClaims.cs b/src/Squidex.Infrastructure/Security/OpenIdClaims.cs new file mode 100644 index 000000000..fc2070abd --- /dev/null +++ b/src/Squidex.Infrastructure/Security/OpenIdClaims.cs @@ -0,0 +1,38 @@ +// ========================================================================== +// OpenIdClaims.cs +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex Group +// All rights reserved. +// ========================================================================== + +namespace Squidex.Infrastructure.Security +{ + public class OpenIdClaims + { + /// + /// Unique Identifier for the End-User at the Issuer. + /// + public const string Subject = "sub"; + + /// + /// End-User's full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User's locale and preferences. + /// + public const string Name = "name"; + + /// + /// Casual name of the End-User that may or may not be the same as the given_name. For instance, a nickname value of Mike might be returned alongside a given_name value of Michael. + /// + public const string NickName = "nickname"; + + /// + /// Shorthand name by which the End-User wishes to be referred to at the + /// + public const string PreferredUserName = "preferred_username"; + + /// + /// End-User's preferred e-mail address. + /// + public const string Email = "email"; + } +} diff --git a/src/Squidex.Infrastructure/project.json b/src/Squidex.Infrastructure/project.json index 0cba50096..76273b30b 100644 --- a/src/Squidex.Infrastructure/project.json +++ b/src/Squidex.Infrastructure/project.json @@ -9,7 +9,8 @@ "NodaTime": "2.0.0-alpha20160729", "protobuf-net": "2.1.0", "System.Linq": "4.1.0", - "System.Reflection.TypeExtensions": "4.1.0" + "System.Reflection.TypeExtensions": "4.1.0", + "System.Security.Claims": "4.0.1" }, "frameworks": { "netcoreapp1.0": { diff --git a/src/Squidex.Store.MongoDb/Apps/MongoAppEntity.cs b/src/Squidex.Store.MongoDb/Apps/MongoAppEntity.cs index b50c87cff..dc8ec084d 100644 --- a/src/Squidex.Store.MongoDb/Apps/MongoAppEntity.cs +++ b/src/Squidex.Store.MongoDb/Apps/MongoAppEntity.cs @@ -6,7 +6,6 @@ // All rights reserved. // ========================================================================== -using System; using System.Collections.Generic; using MongoDB.Bson.Serialization.Attributes; using Squidex.Read.Apps; diff --git a/src/Squidex.Store.MongoDb/Apps/MongoAppRepository.cs b/src/Squidex.Store.MongoDb/Apps/MongoAppRepository.cs index eabe3dff3..132201159 100644 --- a/src/Squidex.Store.MongoDb/Apps/MongoAppRepository.cs +++ b/src/Squidex.Store.MongoDb/Apps/MongoAppRepository.cs @@ -61,7 +61,7 @@ namespace Squidex.Store.MongoDb.Apps public Task On(AppContributorAssigned @event, EnvelopeHeaders headers) { - return Collection.CreateAsync(headers, a => + return Collection.UpdateAsync(headers, a => { var contributor = a.Contributors.Find(x => x.SubjectId == @event.SubjectId); diff --git a/src/Squidex/app/app.module.ts b/src/Squidex/app/app.module.ts index 25ff393b6..a0ddf3118 100644 --- a/src/Squidex/app/app.module.ts +++ b/src/Squidex/app/app.module.ts @@ -10,21 +10,19 @@ import * as Ng2Browser from '@angular/platform-browser'; import { AppComponent } from './app.component'; -import { +import { ApiUrlConfig, + AppsStoreService, + AppsService, + AuthGuard, + AuthService, CurrencyConfig, DragService, DragServiceFactory, DecimalSeparatorConfig, + SqxFrameworkModule, TitlesConfig, TitleService -} from './framework'; - -import { - AppsStoreService, - AppsService, - AuthGuard, - AuthService, } from './shared'; import { @@ -34,8 +32,6 @@ import { SqxPublicModule } from './components'; -import { SqxFrameworkModule } from './framework'; - import { routing } from './app.routes'; const baseUrl = window.location.protocol + '//' + window.location.host + '/'; diff --git a/src/Squidex/app/components/auth/index.ts b/src/Squidex/app/components/auth/index.ts index 25d07ecaf..92d9707a0 100644 --- a/src/Squidex/app/components/auth/index.ts +++ b/src/Squidex/app/components/auth/index.ts @@ -6,5 +6,4 @@ */ export * from './declarations'; - -export * from './auth.module'; \ No newline at end of file +export * from './module'; \ No newline at end of file diff --git a/src/Squidex/app/components/auth/login-page.component.ts b/src/Squidex/app/components/auth/login-page.component.ts index bfa8d59b9..257bf28b8 100644 --- a/src/Squidex/app/components/auth/login-page.component.ts +++ b/src/Squidex/app/components/auth/login-page.component.ts @@ -8,9 +8,7 @@ import * as Ng2 from '@angular/core'; import * as Ng2Router from '@angular/router'; -import { AuthService } from './../../shared'; - -import { TitleService } from './../../framework'; +import { AuthService, TitleService } from 'shared'; @Ng2.Component({ selector: 'login', diff --git a/src/Squidex/app/components/auth/logout-page.component.ts b/src/Squidex/app/components/auth/logout-page.component.ts index 4bb40a079..a4deb1536 100644 --- a/src/Squidex/app/components/auth/logout-page.component.ts +++ b/src/Squidex/app/components/auth/logout-page.component.ts @@ -8,7 +8,7 @@ import * as Ng2 from '@angular/core'; import * as Ng2Router from '@angular/router'; -import { AuthService } from './../../shared'; +import { AuthService } from 'shared'; @Ng2.Component({ selector: 'logout', diff --git a/src/Squidex/app/components/auth/auth.module.ts b/src/Squidex/app/components/auth/module.ts similarity index 81% rename from src/Squidex/app/components/auth/auth.module.ts rename to src/Squidex/app/components/auth/module.ts index 7571b5af9..5ce195873 100644 --- a/src/Squidex/app/components/auth/auth.module.ts +++ b/src/Squidex/app/components/auth/module.ts @@ -7,7 +7,7 @@ import * as Ng2 from '@angular/core'; -import { SqxFrameworkModule } from './../../framework'; +import { SqxFrameworkModule } from 'shared'; import { LoginPageComponent, diff --git a/src/Squidex/app/components/internal/apps/apps-page.component.scss b/src/Squidex/app/components/internal/apps/apps-page.component.scss index 9e6c5e57d..8542b6176 100644 --- a/src/Squidex/app/components/internal/apps/apps-page.component.scss +++ b/src/Squidex/app/components/internal/apps/apps-page.component.scss @@ -1,5 +1,5 @@ -@import '../../../theme/_vars.scss'; -@import '../../../theme/_mixins.scss'; +@import '_vars.scss'; +@import '_mixins.scss'; content { padding: 20px; diff --git a/src/Squidex/app/components/internal/apps/apps-page.component.ts b/src/Squidex/app/components/internal/apps/apps-page.component.ts index b22996e4b..8d15b2a31 100644 --- a/src/Squidex/app/components/internal/apps/apps-page.component.ts +++ b/src/Squidex/app/components/internal/apps/apps-page.component.ts @@ -11,7 +11,7 @@ import { fadeAnimation, ModalView, TitleService -} from './../../../framework'; +} from 'shared'; @Ng2.Component({ selector: 'sqx-apps-page', diff --git a/src/Squidex/app/components/internal/index.ts b/src/Squidex/app/components/internal/index.ts index 2b7d13e58..da3622ff0 100644 --- a/src/Squidex/app/components/internal/index.ts +++ b/src/Squidex/app/components/internal/index.ts @@ -6,5 +6,4 @@ */ export * from './declarations'; - -export * from './internal.module'; \ No newline at end of file +export * from './module'; \ No newline at end of file diff --git a/src/Squidex/app/components/internal/internal-area.component.scss b/src/Squidex/app/components/internal/internal-area.component.scss index 49eefdd70..5d5df4fdd 100644 --- a/src/Squidex/app/components/internal/internal-area.component.scss +++ b/src/Squidex/app/components/internal/internal-area.component.scss @@ -1,4 +1,5 @@ -@import '../../theme/mixins.scss'; +@import '_vars.scss'; +@import '_mixins.scss'; .navbar { @include box-shadow(0, 4px, 4px, 0.2px); diff --git a/src/Squidex/app/components/internal/internal-area.component.ts b/src/Squidex/app/components/internal/internal-area.component.ts index 6c5d0577a..3344ebcb5 100644 --- a/src/Squidex/app/components/internal/internal-area.component.ts +++ b/src/Squidex/app/components/internal/internal-area.component.ts @@ -11,7 +11,7 @@ import { fadeAnimation, ModalView, TitleService -} from './../../framework'; +} from 'shared'; @Ng2.Component({ selector: 'sqx-internal-area', diff --git a/src/Squidex/app/components/internal/internal.module.ts b/src/Squidex/app/components/internal/module.ts similarity index 79% rename from src/Squidex/app/components/internal/internal.module.ts rename to src/Squidex/app/components/internal/module.ts index 42e873b5f..8fa1ab848 100644 --- a/src/Squidex/app/components/internal/internal.module.ts +++ b/src/Squidex/app/components/internal/module.ts @@ -7,8 +7,8 @@ import * as Ng2 from '@angular/core'; -import { SqxFrameworkModule } from './../../framework'; -import { SqxLayoutModule } from './../layout'; +import { SqxFrameworkModule } from 'shared'; +import { SqxLayoutModule } from 'components/layout'; import { AppAreaComponent, diff --git a/src/Squidex/app/components/layout/app-form.component.scss b/src/Squidex/app/components/layout/app-form.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/Squidex/app/components/layout/app-form.component.ts b/src/Squidex/app/components/layout/app-form.component.ts index 90b7ead46..632abfeab 100644 --- a/src/Squidex/app/components/layout/app-form.component.ts +++ b/src/Squidex/app/components/layout/app-form.component.ts @@ -10,15 +10,16 @@ import * as Ng2Forms from '@angular/forms'; import { BehaviorSubject } from 'rxjs'; -import { fadeAnimation } from './../../framework'; - -import { AppCreateDto, AppsStoreService } from './../../shared'; +import { + AppCreateDto, + AppsStoreService, + fadeAnimation +} from 'shared'; const FALLBACK_NAME = 'my-app'; @Ng2.Component({ selector: 'sqx-app-form', - styles, template, animations: [ fadeAnimation() diff --git a/src/Squidex/app/components/layout/apps-menu.component.scss b/src/Squidex/app/components/layout/apps-menu.component.scss index 6f601d97d..7a10bcb7e 100644 --- a/src/Squidex/app/components/layout/apps-menu.component.scss +++ b/src/Squidex/app/components/layout/apps-menu.component.scss @@ -27,23 +27,6 @@ width: 0; } -.all-apps { - & { - position: relative; - } - - &-text { - font-weight: bold; - } - - &-pill { - @include absolute(6px, 10px, auto, auto); - color: $accent-blue; - border: none; - background: $accent-blue-lighter; - } -} - #app-name { & { padding-right: 15px; diff --git a/src/Squidex/app/components/layout/apps-menu.component.ts b/src/Squidex/app/components/layout/apps-menu.component.ts index b7c6c39d0..b56ff4c15 100644 --- a/src/Squidex/app/components/layout/apps-menu.component.ts +++ b/src/Squidex/app/components/layout/apps-menu.component.ts @@ -8,9 +8,11 @@ import * as Ng2 from '@angular/core'; import * as Ng2Router from '@angular/router'; -import { AppsStoreService } from 'shared'; - -import { fadeAnimation, ModalView } from 'framework'; +import { + AppsStoreService, + fadeAnimation, + ModalView +} from 'shared'; const FALLBACK_NAME = 'Apps Overview'; diff --git a/src/Squidex/app/components/layout/index.ts b/src/Squidex/app/components/layout/index.ts index 3f66f638f..92d9707a0 100644 --- a/src/Squidex/app/components/layout/index.ts +++ b/src/Squidex/app/components/layout/index.ts @@ -6,5 +6,4 @@ */ export * from './declarations'; - -export * from './layout.module'; \ No newline at end of file +export * from './module'; \ No newline at end of file diff --git a/src/Squidex/app/components/layout/layout.module.ts b/src/Squidex/app/components/layout/module.ts similarity index 87% rename from src/Squidex/app/components/layout/layout.module.ts rename to src/Squidex/app/components/layout/module.ts index 52858bec2..9b3b6f2d2 100644 --- a/src/Squidex/app/components/layout/layout.module.ts +++ b/src/Squidex/app/components/layout/module.ts @@ -7,7 +7,7 @@ import * as Ng2 from '@angular/core'; -import { SqxFrameworkModule } from './../../framework'; +import { SqxFrameworkModule } from 'shared'; import { AppFormComponent, diff --git a/src/Squidex/app/components/layout/search-form.component.scss b/src/Squidex/app/components/layout/search-form.component.scss index b703e4d4b..0d53f4cbc 100644 --- a/src/Squidex/app/components/layout/search-form.component.scss +++ b/src/Squidex/app/components/layout/search-form.component.scss @@ -1,5 +1,5 @@ -@import '../../theme/_vars.scss'; -@import '../../theme/_mixins.scss'; +@import '_vars.scss'; +@import '_mixins.scss'; .search { & { diff --git a/src/Squidex/app/components/public/index.ts b/src/Squidex/app/components/public/index.ts index 8c8ba34d4..92d9707a0 100644 --- a/src/Squidex/app/components/public/index.ts +++ b/src/Squidex/app/components/public/index.ts @@ -6,5 +6,4 @@ */ export * from './declarations'; - -export * from './public.module'; \ No newline at end of file +export * from './module'; \ No newline at end of file diff --git a/src/Squidex/app/components/public/public.module.ts b/src/Squidex/app/components/public/module.ts similarity index 79% rename from src/Squidex/app/components/public/public.module.ts rename to src/Squidex/app/components/public/module.ts index d3443c5c4..fbad23b93 100644 --- a/src/Squidex/app/components/public/public.module.ts +++ b/src/Squidex/app/components/public/module.ts @@ -7,7 +7,7 @@ import * as Ng2 from '@angular/core'; -import { SqxFrameworkModule } from './../../framework'; +import { SqxFrameworkModule } from 'shared'; import { NotFoundPageComponent, diff --git a/src/Squidex/app/components/public/not-found-page.component.ts b/src/Squidex/app/components/public/not-found-page.component.ts index ef9cdaaa9..5943bfc4e 100644 --- a/src/Squidex/app/components/public/not-found-page.component.ts +++ b/src/Squidex/app/components/public/not-found-page.component.ts @@ -7,7 +7,7 @@ import * as Ng2 from '@angular/core'; -import { TitleService } from './../../framework'; +import { TitleService } from 'shared'; @Ng2.Component({ selector: 'not-found', diff --git a/src/Squidex/app/framework/index.ts b/src/Squidex/app/framework/index.ts index 7b39fb2ac..da3622ff0 100644 --- a/src/Squidex/app/framework/index.ts +++ b/src/Squidex/app/framework/index.ts @@ -6,5 +6,4 @@ */ export * from './declarations'; - -export * from './framework.module'; \ No newline at end of file +export * from './module'; \ No newline at end of file diff --git a/src/Squidex/app/framework/framework.module.ts b/src/Squidex/app/framework/module.ts similarity index 100% rename from src/Squidex/app/framework/framework.module.ts rename to src/Squidex/app/framework/module.ts diff --git a/src/Squidex/app/shared/index.ts b/src/Squidex/app/shared/index.ts index e4c1a1998..51428ba59 100644 --- a/src/Squidex/app/shared/index.ts +++ b/src/Squidex/app/shared/index.ts @@ -8,4 +8,6 @@ export * from './guards/auth.guard'; export * from './services/apps-store.service'; export * from './services/apps.service'; -export * from './services/auth.service'; \ No newline at end of file +export * from './services/auth.service'; + +export * from 'framework'; \ No newline at end of file diff --git a/src/Squidex/app/shared/services/apps.service.ts b/src/Squidex/app/shared/services/apps.service.ts index 83ec7817e..18b37eb74 100644 --- a/src/Squidex/app/shared/services/apps.service.ts +++ b/src/Squidex/app/shared/services/apps.service.ts @@ -9,7 +9,8 @@ import * as Ng2 from '@angular/core'; import { Observable } from 'rxjs'; -import { ApiUrlConfig, DateTime } from './../../framework'; +import { ApiUrlConfig, DateTime } from 'framework'; + import { AuthService } from './auth.service'; export class AppDto { diff --git a/src/Squidex/app/shared/services/auth.service.ts b/src/Squidex/app/shared/services/auth.service.ts index 0d8ae93af..fd30c3950 100644 --- a/src/Squidex/app/shared/services/auth.service.ts +++ b/src/Squidex/app/shared/services/auth.service.ts @@ -17,7 +17,7 @@ import { import { BehaviorSubject, Observable } from 'rxjs'; -import { ApiUrlConfig } from './../../framework'; +import { ApiUrlConfig } from 'framework'; @Ng2.Injectable() export class AuthService {