Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spaceAuthorization removed dependency on account authorization #4711

Merged
merged 136 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 133 commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
76a4541
first pass at two new modules for TemplatesManager, TemplateDefault
techsmyth Sep 29, 2024
d01f378
added templates manager to space; removed the SpaceDefaults entity (m…
techsmyth Sep 29, 2024
862e754
added templatesManager to platform
techsmyth Sep 29, 2024
821a96d
moved creating of default innovatin flow input to space defaults
techsmyth Sep 29, 2024
fffaedf
back out space type on Template; tidy up Template module to use switc…
techsmyth Sep 29, 2024
1ac872d
created template applier module
techsmyth Sep 29, 2024
cc60f0d
tidy up naming
techsmyth Sep 29, 2024
09cbbdb
updated set of default template types
techsmyth Sep 29, 2024
04ba73a
fixed circular dependency; moved logic for creating collaboration inp…
techsmyth Sep 29, 2024
00038d5
removed loading of defaults from files for collaboration content
techsmyth Sep 29, 2024
fc4f6e3
removed code based addition of callouts, innovation flow states
techsmyth Sep 29, 2024
df626dd
merge from roles
techsmyth Sep 29, 2024
22300bc
merge from roles; added definitions to bootstrap folder
techsmyth Oct 1, 2024
55ff03c
tidy up naming
techsmyth Oct 1, 2024
0d9c7b4
Merge branch 'roles' into subspaceTemplates
techsmyth Oct 1, 2024
064cf23
Merge branch 'develop' into subspaceTemplates
techsmyth Oct 1, 2024
f56122b
added loading of default templates at platform level in to bootstrap
techsmyth Oct 1, 2024
f8cfd6c
removed option to create new innovation flow template
techsmyth Oct 1, 2024
bfaa76d
added in migration:
techsmyth Oct 1, 2024
9b428dd
loading in templates on bootstrap
techsmyth Oct 1, 2024
02239be
added field for collaboration templates on templatesSet; added lookup…
techsmyth Oct 1, 2024
11fc8cd
added mutation to create template from collaboration; added logic to …
techsmyth Oct 2, 2024
db2d78c
Merge remote-tracking branch 'origin/develop' into subspaceTemplates
ccanos Oct 3, 2024
d497688
Merge branch 'develop' into subspaceTemplates
ccanos Oct 3, 2024
04b9c72
Merge branch 'develop' into subspaceTemplates
techsmyth Oct 6, 2024
d4ec58f
Merge branch 'subspaceTemplates' of https://github.com/alkem-io/serve…
techsmyth Oct 6, 2024
da5ff7c
initial creation of license + entitlements modules
techsmyth Oct 6, 2024
400319e
add license into account
techsmyth Oct 6, 2024
f57142e
updated account to have license service + use that in mutations check…
techsmyth Oct 6, 2024
1ec83f3
ensure data is loaded properly on account for license checking
techsmyth Oct 6, 2024
2aa96f7
added mutation to reset the license calculations on account, includin…
techsmyth Oct 6, 2024
ed45adb
renamed Licensing module to LicensingFramework module; trigger licens…
techsmyth Oct 6, 2024
2d13bc6
removed usage of LicenseEngine outside of license services on space o…
techsmyth Oct 6, 2024
e1f0cff
renamed entitlement to licenseEntitlement as entity; first pass at mi…
techsmyth Oct 6, 2024
8f51052
fixed issues in migration
techsmyth Oct 6, 2024
862f282
fixed issues related to auth reset; tidied up loader creator imports
techsmyth Oct 6, 2024
20e4ef1
fixed auth cascade for templates of type post
techsmyth Oct 6, 2024
dc63e82
license reset running
techsmyth Oct 6, 2024
8343974
reset licenses on space after adding / removing license plans
techsmyth Oct 6, 2024
7b2bc0b
removed need for license check in community; added entitlement check …
techsmyth Oct 6, 2024
1184725
remove auth reset when assigning / removing license plans
techsmyth Oct 6, 2024
14fbfa8
added License to RoleSet
techsmyth Oct 6, 2024
b22514e
added license to collaboration
techsmyth Oct 7, 2024
fcaf0d7
tidied up retrieval of license for whiteboard; added license to colla…
techsmyth Oct 7, 2024
3095e32
fix typo; fix space spec file
techsmyth Oct 7, 2024
2a2e46b
fix additional tests
techsmyth Oct 7, 2024
7b00065
Merge branch 'develop' into subspaceTemplates
techsmyth Oct 7, 2024
8d7b917
moved tempaltesManager to last migration in the list
techsmyth Oct 7, 2024
f301d80
fixed retrieval of template when creating collaboration
techsmyth Oct 8, 2024
3a6174f
added logging
techsmyth Oct 8, 2024
d8ab18b
fixed bootstrap setting of templates
techsmyth Oct 8, 2024
89260bf
refactored inputCreator to do the data loading closer to usage; fixed…
techsmyth Oct 8, 2024
e9f3db2
Merge branch 'subspaceTemplates' into entitlements
techsmyth Oct 8, 2024
66f5e76
added ability to retrieve limits on entitlements + current usage
techsmyth Oct 8, 2024
fbb85a9
updated field names on entitlements
techsmyth Oct 8, 2024
401aca9
updated field names on entitlements
techsmyth Oct 8, 2024
9a8bbdb
fixed account mutaiton logic bug
techsmyth Oct 8, 2024
83f62d5
ensure that licenses are reset when assigning beta tester or vc campa…
techsmyth Oct 8, 2024
b6fa9d5
added reset all account licenses mutation
techsmyth Oct 8, 2024
c52119d
fixed bug on space entitlements; refactored code to reduce duplication
techsmyth Oct 9, 2024
cda9cb7
Merge branch 'develop' into subspaceTemplates
techsmyth Oct 9, 2024
15ec6b8
fixed url generation for templates inside of TempaltesManager
techsmyth Oct 10, 2024
74d3b1d
fixed bootstrap order to create forum earlier
techsmyth Oct 10, 2024
cd8332f
ensure collaboration creation on template provides some defaults for …
techsmyth Oct 10, 2024
56f47c5
fix deletion of templates of type post
techsmyth Oct 10, 2024
486c788
ensure more data is defaulted inside of template service for collabor…
techsmyth Oct 11, 2024
c7b2a28
ensure isTempalte is passed to Collaboration entity
techsmyth Oct 11, 2024
81985c0
merge from parent branch
techsmyth Oct 11, 2024
79c08ab
fixed groups in bootstrap space template; updated signature for creat…
techsmyth Oct 11, 2024
f989d0a
fixed missing field
techsmyth Oct 11, 2024
2052f32
fixed type on mutation to create from collaboration
techsmyth Oct 11, 2024
8489d34
fixed typo
techsmyth Oct 11, 2024
c61560d
fixed groups in bootstrap space template; updated signature for creat…
techsmyth Oct 11, 2024
446232b
fixed missing field
techsmyth Oct 11, 2024
6eaf99e
fixed type on mutation to create from collaboration
techsmyth Oct 11, 2024
b53c77e
fixed typo
techsmyth Oct 11, 2024
6057a74
reworked applying collaboraiton template to collaboration
techsmyth Oct 11, 2024
5025c60
improved error message in wrong type of ID passed in
techsmyth Oct 12, 2024
45e2996
fixed build
techsmyth Oct 12, 2024
5232146
Merge branch 'subspaceTemplates' into entitlements
techsmyth Oct 12, 2024
228c8b7
Merge branch 'develop' into subspaceTemplates
techsmyth Oct 12, 2024
df2491f
Merge branch 'develop' into subspaceTemplates
techsmyth Oct 14, 2024
f9c50cb
merge from develop
techsmyth Oct 16, 2024
eabfc05
made migration last in the list
techsmyth Oct 16, 2024
2303684
merge from base branch
techsmyth Oct 16, 2024
74ae062
rename migration to be last
techsmyth Oct 16, 2024
29228d9
removed read check when looking up collaboration
techsmyth Oct 16, 2024
cb78b63
Merge branch 'develop' into subspaceTemplates
ccanos Oct 18, 2024
f66990c
Merge branch 'develop' into subspaceTemplates
ccanos Oct 22, 2024
da80f4a
Merge branch 'subspaceTemplates' into entitlements
techsmyth Oct 22, 2024
315f81e
track free / plus / premium space entitlements separately
techsmyth Oct 22, 2024
36d0c5b
initial merge from develop
techsmyth Nov 3, 2024
60a1a6d
updated migration order
techsmyth Nov 3, 2024
d8588e5
removed duplicate migration
techsmyth Nov 4, 2024
ffc8379
moved auth reset to mutation for applying the template to another col…
techsmyth Nov 4, 2024
18f8f40
fixed more merge conflicts from develop
techsmyth Nov 5, 2024
45f23c9
extend lookup of entitlement usage to cover new types
techsmyth Nov 5, 2024
09ceebe
updaed license policy to reflect new entitlements; made license engin…
techsmyth Nov 5, 2024
683f1f0
updated migration to not drop indexes already removed
techsmyth Nov 5, 2024
1f1370a
fix for license reset on space
techsmyth Nov 5, 2024
e2c35c8
added license policy rule for free space credential
techsmyth Nov 5, 2024
aea78f7
ensure license entitlements are reset as part of the bootstrap
techsmyth Nov 5, 2024
a587378
fixed typo
techsmyth Nov 5, 2024
fe52ac7
Merge branch 'develop' into entitlements
techsmyth Nov 5, 2024
2d41f91
merge from develop
techsmyth Nov 8, 2024
e4c0df1
extended reset all to include resetting licenses on accounts + AI ser…
techsmyth Nov 8, 2024
6878843
merge from develop
techsmyth Nov 9, 2024
b3c33f6
Merge branch 'develop' into entitlements
valentinyanakiev Nov 11, 2024
4da2ef7
Address pr comment
valentinyanakiev Nov 11, 2024
f1d5c03
Address PR feedback
valentinyanakiev Nov 11, 2024
2d56b51
Address PR comment
valentinyanakiev Nov 11, 2024
81fa8cb
Address PR comments
valentinyanakiev Nov 11, 2024
9e5a53c
Merge remote-tracking branch 'origin/entitlements' into entitlements
valentinyanakiev Nov 11, 2024
1b59c05
Address PR comments
valentinyanakiev Nov 12, 2024
62d0bc9
Address PR comment
valentinyanakiev Nov 12, 2024
928e641
Improved types & naming
valentinyanakiev Nov 12, 2024
516ca9e
Merge branch 'develop' into entitlements
valentinyanakiev Nov 12, 2024
a3ffeae
Address PR comments
valentinyanakiev Nov 12, 2024
39756be
Fixed switch-case logic in entitlements
valentinyanakiev Nov 12, 2024
5680b57
Converge entitlements schema
valentinyanakiev Nov 13, 2024
438811e
Remove unused AuthorizationPrivilege
valentinyanakiev Nov 13, 2024
a799120
pass in spaceID on space authorization as reload the entity
techsmyth Nov 14, 2024
8af18a4
initial rework of the space authorization to clean up logic so that t…
techsmyth Nov 17, 2024
792c0d3
removed privileges on space that are no longer used there
techsmyth Nov 17, 2024
28cbf62
merge from develop
techsmyth Nov 17, 2024
15347b8
minor tidy up
techsmyth Nov 17, 2024
2a5cdb3
fixed logic check: space auth does need license entitlements
techsmyth Nov 17, 2024
c0dc613
Merge branch 'develop' into server-4710-spaceAuth
techsmyth Nov 25, 2024
06c2439
Merge branch 'develop' into server-4710-spaceAuth
techsmyth Dec 4, 2024
6f0516d
Merge branch 'develop' into server-4710-spaceAuth
techsmyth Dec 6, 2024
d8674c0
Merge branch 'develop' into server-4710-spaceAuth
techsmyth Dec 7, 2024
3f5be71
take rabbit suggestion
techsmyth Dec 7, 2024
78db96b
Merge branch 'develop' into server-4710-spaceAuth
valentinyanakiev Dec 9, 2024
5062fd5
Merge branch 'develop' into server-4710-spaceAuth
valentinyanakiev Dec 11, 2024
bd51bf4
Propagate anonymousReadAccess from parentAuthorization for Space
valentinyanakiev Dec 11, 2024
8cdf82f
Merge branch 'develop' into server-4710-spaceAuth
valentinyanakiev Dec 11, 2024
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
2 changes: 1 addition & 1 deletion src/core/bootstrap/bootstrap.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ export class BootstrapService {

const space = await this.accountService.createSpaceOnAccount(spaceInput);
const spaceAuthorizations =
await this.spaceAuthorizationService.applyAuthorizationPolicy(space);
await this.spaceAuthorizationService.applyAuthorizationPolicy(space.id);
await this.authorizationPolicyService.saveAll(spaceAuthorizations);

const accountEntitlements =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseAlkemioEntity } from '@domain/common/entity/base-entity';
import { Column, Entity } from 'typeorm';
import { Column, Entity, ManyToOne } from 'typeorm';
import { IAuthorizationPolicy } from './authorization.policy.interface';
import { AuthorizationPolicyType } from '@common/enums/authorization.policy.type';
import { ENUM_LENGTH } from '@common/constants';
Expand All @@ -24,6 +24,16 @@ export class AuthorizationPolicy
@Column('varchar', { length: ENUM_LENGTH, nullable: false })
type!: AuthorizationPolicyType;

// An authorization can optionally choose to store a reference to the parent authorization from which it inherits
// This is useful for when the entity wants to adjust its settings + may no longer have access without hacky code
// to the authorization of the containing entity
@ManyToOne(() => AuthorizationPolicy, {
eager: false,
cascade: false, // MUST not cascade
onDelete: 'SET NULL',
})
parentAuthorizationPolicy?: AuthorizationPolicy;

constructor(type: AuthorizationPolicyType) {
super();
this.anonymousReadAccess = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export abstract class IAuthorizationPolicy extends IBaseAlkemio {
verifiedCredentialRules!: string;
privilegeRules!: string;

parentAuthorizationPolicy?: IAuthorizationPolicy;

@Field(() => AuthorizationPolicyType, {
nullable: true,
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class AuthorizationPolicyService {
return authorization;
}

reset(
public reset(
authorizationPolicy: IAuthorizationPolicy | undefined
): IAuthorizationPolicy {
if (!authorizationPolicy) {
Expand Down
4 changes: 2 additions & 2 deletions src/domain/space/account/account.resolver.mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class AccountResolverMutations {
space = await this.spaceService.save(space);

const spaceAuthorizations =
await this.spaceAuthorizationService.applyAuthorizationPolicy(space);
await this.spaceAuthorizationService.applyAuthorizationPolicy(space.id);
await this.authorizationPolicyService.saveAll(spaceAuthorizations);

const updatedLicenses = await this.spaceLicenseService.applyLicensePolicy(
Expand Down Expand Up @@ -424,7 +424,7 @@ export class AccountResolverMutations {
space = await this.spaceService.save(space);

const spaceAuthorizations =
await this.spaceAuthorizationService.applyAuthorizationPolicy(space);
await this.spaceAuthorizationService.applyAuthorizationPolicy(space.id);
await this.authorizationPolicyService.saveAll(spaceAuthorizations);
// TODO: check if still needed later
return await this.spaceService.getSpaceOrFail(space.id);
Expand Down
10 changes: 5 additions & 5 deletions src/domain/space/account/account.service.authorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,9 @@ export class AccountAuthorizationService {
}
const updatedAuthorizations: IAuthorizationPolicy[] = [];

const clonedAccountAuth =
await this.getClonedAccountAuthExtendedForChildEntities(account);

for (const space of account.spaces) {
const spaceAuthorizations =
await this.spaceAuthorizationService.applyAuthorizationPolicy(space);
await this.spaceAuthorizationService.applyAuthorizationPolicy(space.id);
this.logger.verbose?.(
`space nameID ${space.nameID}: authorizations to reset count = ${spaceAuthorizations.length}`,
LogContext.AUTH
Expand Down Expand Up @@ -178,6 +175,10 @@ export class AccountAuthorizationService {
);
updatedAuthorizations.push(...storageAggregatorAuthorizations);

// For the VCs, InnovationPacks + InnovationHubs use a cloned + extended authorization
const clonedAccountAuth =
await this.getClonedAccountAuthExtendedForChildEntities(account);

for (const vc of account.virtualContributors) {
const updatedVcAuthorizations =
await this.virtualContributorAuthorizationService.applyAuthorizationPolicy(
Expand Down Expand Up @@ -281,7 +282,6 @@ export class AccountAuthorizationService {
accountHostManage.cascade = true;
newRules.push(accountHostManage);

// If the user is a beta tester or part of VC campaign then can create the resources
const createSpace = this.authorizationPolicyService.createCredentialRule(
[AuthorizationPrivilege.CREATE_SPACE],
[...hostCredentials],
Expand Down
9 changes: 6 additions & 3 deletions src/domain/space/space/space.resolver.mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class SpaceResolverMutations {
// but not all settings will require this, so only update if necessary
if (shouldUpdateAuthorization) {
const updatedAuthorizations =
await this.spaceAuthorizationService.applyAuthorizationPolicy(space);
await this.spaceAuthorizationService.applyAuthorizationPolicy(space.id);
await this.authorizationPolicyService.saveAll(updatedAuthorizations);
}

Expand Down Expand Up @@ -168,7 +168,7 @@ export class SpaceResolverMutations {
);
space = await this.spaceService.save(space);
const updatedAuthorizations =
await this.spaceAuthorizationService.applyAuthorizationPolicy(space);
await this.spaceAuthorizationService.applyAuthorizationPolicy(space.id);
await this.authorizationPolicyService.saveAll(updatedAuthorizations);

return await this.spaceService.getSpaceOrFail(space.id);
Expand Down Expand Up @@ -200,7 +200,10 @@ export class SpaceResolverMutations {
// Save here so can reuse it later without another load
const displayName = subspace.profile.displayName;
const updatedAuthorizations =
await this.spaceAuthorizationService.applyAuthorizationPolicy(subspace);
await this.spaceAuthorizationService.applyAuthorizationPolicy(
subspace.id,
space.authorization // Important, and will be stored
);

await this.authorizationPolicyService.saveAll(updatedAuthorizations);

Expand Down
Loading