Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
226 commits
Select commit Hold shift + click to select a range
9da6f4e
Bump debian from `b5ace51` to `5724d31` in /src/main/docker
dependabot[bot] Feb 10, 2025
570dad1
Fix `DbUtil` not being initialized
nscuro Feb 12, 2025
9624f57
Bump lib.net.javacrumbs.shedlock.version from 6.2.0 to 6.3.0
dependabot[bot] Feb 17, 2025
7007af1
refactor: add changeset for new tables
jhoward-lm Feb 17, 2025
687bce6
fix: changeset unique constraints
jhoward-lm Feb 20, 2025
af04fb2
Mirror container images to Docker Hub
nscuro Feb 18, 2025
391a155
Fix erroneous over-suppression of Snyk findings
nscuro Feb 19, 2025
8afb4be
Populate audit trail when auto-suppressing withdrawn Snyk findings
nscuro Feb 19, 2025
71f2ccb
Log deleted project info + fix nullPointerException (#1064)
sahibamittal Feb 19, 2025
28906c8
Bump lib.testcontainers.version from 1.20.4 to 1.20.5
dependabot[bot] Feb 20, 2025
2f0baf6
Bump org.apache.maven.plugins:maven-clean-plugin from 3.4.0 to 3.4.1
dependabot[bot] Feb 20, 2025
09f3e4f
fix: changeset unique constraints
jhoward-lm Feb 21, 2025
5dd0891
Consider project hierarchies for portfolio ACL checks
nscuro Feb 17, 2025
bdaf5ee
feat: add role and mappedrole classes (#2)
ashearin Feb 24, 2025
70a30fc
Define new Role permissisons & Initial creation of RoleResource.java …
jmayer-lm Feb 25, 2025
4c61f7c
add roleQueryManager method stubs (#6)
lmphil Feb 26, 2025
0bcefd8
Add /v1/user Endpoints & CRUD Method Stubs (#7)
jmayer-lm Feb 27, 2025
df11a6c
Add default roles and permissions for project management (#8)
EphraimEM Feb 27, 2025
781656c
cleaup createRoles and loadDefaultRoles
ashearin Feb 27, 2025
594ca9c
Bump org.slf4j:log4j-over-slf4j from 2.0.16 to 2.0.17
dependabot[bot] Feb 26, 2025
16610e2
Flesh out stubbed api endpoints, call createDefaultRoles
ashearin Feb 27, 2025
dd808a3
update getRoles
ashearin Feb 27, 2025
7b301be
fix: add role UUID field (#9)
jhoward-lm Mar 3, 2025
5731b27
refactor: implement role endpoint methods (#10)
jhoward-lm Mar 3, 2025
d856857
Improve coverage of portfolio ACL checks in REST API endpoints
nscuro Feb 20, 2025
8d6d789
Bump docker/setup-buildx-action from 3.9.0 to 3.10.0
dependabot[bot] Mar 3, 2025
a02d686
Bump docker/build-push-action from 6.13.0 to 6.15.0
dependabot[bot] Mar 3, 2025
93a5440
Bump actions/download-artifact from 4.1.8 to 4.1.9
dependabot[bot] Mar 3, 2025
9370cb8
Bump docker/setup-qemu-action from 3.4.0 to 3.6.0
dependabot[bot] Mar 3, 2025
98948b9
Bump actions/upload-artifact from 4.6.0 to 4.6.1
dependabot[bot] Mar 3, 2025
6820bda
Bump debian from `5724d31` to `5484adc` in /src/main/docker
dependabot[bot] Mar 3, 2025
39734cf
Bump org.wiremock:wiremock from 3.12.0 to 3.12.1
dependabot[bot] Mar 3, 2025
f26f12f
refactor: implement adding/removing users to/from roles (#13)
jhoward-lm Mar 4, 2025
399bd90
Merge branch 'main' of https://github.com/ashearin/hyades-apiserver i…
ashearin Mar 4, 2025
3e1f95b
refactor: remove description field
ashearin Mar 4, 2025
32b43a7
remove tostring bug, update role serialVersionID
ashearin Mar 10, 2025
cafffc8
add getunassignedprojects to role dao.java, getunassignedprojects to …
ashearin Mar 12, 2025
9c1d6ee
addRoleToUser working
ashearin Mar 14, 2025
237d9a0
refactor: flatten user role join tables (#14)
jhoward-lm Mar 17, 2025
ad0b0ff
Merge branch 'main' of https://github.com/ashearin/hyades-apiserver i…
ashearin Mar 17, 2025
c8f65d1
update getunassignedprojects dao query
ashearin Mar 17, 2025
b157864
working getUserRoles and associated mapper/methods/queries, draft rem…
ashearin Mar 19, 2025
fabbe9e
alter getuserUnassignedProjects to not return 404 if no projects are …
ashearin Mar 19, 2025
001d856
refactor: create view of project effective permissions for user (#15)
jhoward-lm Mar 19, 2025
b2cae30
code cleanup
ashearin Mar 20, 2025
25dac1b
Merge branch 'main' of https://github.com/ashearin/hyades-apiserver i…
ashearin Mar 20, 2025
b43a7d3
correct merge issue
ashearin Mar 20, 2025
0c4d41b
Merge branch 'main' of https://github.com/ashearin/hyades-apiserver i…
ashearin Mar 24, 2025
14329aa
Role DAO fixes (#16)
jhoward-lm Mar 24, 2025
535e101
merge corrections
ashearin Mar 24, 2025
c7b7f75
merge corrections
ashearin Mar 25, 2025
238a7cc
revert test changes
ashearin Mar 27, 2025
d0b25c9
Merge branch 'main' of https://github.com/ashearin/hyades-apiserver i…
ashearin Mar 29, 2025
44dd2a2
feat: get user project permissions (wip) (#11)
lmphil Mar 29, 2025
24c66a0
Revert "feat: get user project permissions (wip) (#11)" (#17)
ashearin Mar 29, 2025
be0c3ee
convert roleprojectrequest to record, remove logging, dev change
ashearin Mar 31, 2025
0b8be9a
Merge branch 'main' of https://github.com/ashearin/hyades-apiserver i…
ashearin Apr 1, 2025
6b9bc93
temporary changelog fixes
ashearin Apr 1, 2025
b13b4e8
refactor: add triggers to update effective permissions table with rol…
jhoward-lm Apr 1, 2025
f20717f
revert test change
ashearin Apr 2, 2025
2dcfefa
refactor: add no content response to retrieveUserProjects
ashearin Apr 3, 2025
5edc1e9
feat: initial GitLab integration (WIP)
jhoward-lm Feb 12, 2025
a8918c3
fix: added gitlab auth class
pkwiatkowski1 Feb 12, 2025
86f0913
fixed pom merge issue
pkwiatkowski1 Feb 12, 2025
77ef659
refactor: implement customizer, register event
jhoward-lm Feb 12, 2025
5506eb3
refactor: remove token class member from sync task
jhoward-lm Feb 12, 2025
db1457d
refactor: make user available to syncer
jhoward-lm Feb 12, 2025
cf6a306
fix: remove scheduled task registration
jhoward-lm Feb 12, 2025
b2347e8
style: javadoc list
jhoward-lm Feb 12, 2025
6e0c6d9
refactor: use Event.dispatch, remove pom repository
jhoward-lm Feb 12, 2025
2cedd16
chore: fix pom alpine-parent version and formatting
jhoward-lm Feb 12, 2025
3ee2ef7
added user as syncer class var
pkwiatkowski1 Feb 12, 2025
d817bde
refactor: add GitLabRole enum
jhoward-lm Feb 12, 2025
ea1246a
fix: remove redundant superinterface
jhoward-lm Feb 12, 2025
a4457fc
fix: ensure query manager instantiated
jhoward-lm Feb 12, 2025
dc39b30
fix: implement base Event interface
jhoward-lm Feb 12, 2025
6e8be39
feat: add GitLab Project Class and GitLab graphql query functionality
ashearin Feb 12, 2025
6bf24de
chore: formatting and visibility fixes
ashearin Feb 12, 2025
504c8f4
add map permission to gitlab default roles
EphraimEM Feb 12, 2025
2533d49
add GitlabClientTest file
EphraimEM Feb 12, 2025
ee66deb
modify permission to static member of the class
EphraimEM Feb 12, 2025
5084abc
supress warning on mapPermissionToRoles set to uncheck
EphraimEM Feb 12, 2025
6067d60
clean up remove unused import
EphraimEM Feb 12, 2025
7d76063
add the planner role with permission
EphraimEM Feb 12, 2025
ae936af
chore: refine gitlabsyncer class variables
ashearin Feb 12, 2025
91b0682
refactor: flatten created project structure
jhoward-lm Feb 12, 2025
425621f
fix: add user to GitLab role teams
jhoward-lm Feb 12, 2025
01c8e68
tests: add gitlabsyncer tests
ashearin Feb 13, 2025
f546b72
style: use modern Java conventions
jhoward-lm Feb 13, 2025
3465b52
perf: exclude archived GitLab projects
jhoward-lm Feb 13, 2025
57f7f2f
refactor: configurable GraphQL query inputs
jhoward-lm Feb 13, 2025
4f48c6d
chore: move baseURL initialization to gitlab client constructor
ashearin Feb 13, 2025
1c23235
chore: remove duplicate accesstoken member
ashearin Feb 13, 2025
c36fd93
refactor: locks to manage concurrent project access
jhoward-lm Feb 17, 2025
7fb9a83
add getGitLabProjects unit test
lmphil Feb 24, 2025
c0bd749
refactor: remove GitLabProject name field
jhoward-lm Feb 24, 2025
0ba1ff4
refactor: add GitLab integration constants
jhoward-lm Feb 24, 2025
92e64ec
fix: changeset unique constraints
jhoward-lm Feb 20, 2025
5f8ce34
Consider project hierarchies for portfolio ACL checks
nscuro Feb 17, 2025
9b5972e
feat: add role and mappedrole classes (#2)
ashearin Feb 24, 2025
f2572ca
Define new Role permissisons & Initial creation of RoleResource.java …
jmayer-lm Feb 25, 2025
731b1bf
add roleQueryManager method stubs (#6)
lmphil Feb 26, 2025
2aa0682
Add /v1/user Endpoints & CRUD Method Stubs (#7)
jmayer-lm Feb 27, 2025
9777566
cleaup createRoles and loadDefaultRoles
ashearin Feb 27, 2025
2f8aebd
Bump org.slf4j:log4j-over-slf4j from 2.0.16 to 2.0.17
dependabot[bot] Feb 26, 2025
a81a825
Flesh out stubbed api endpoints, call createDefaultRoles
ashearin Feb 27, 2025
c336548
update getRoles
ashearin Feb 27, 2025
5d0bbc6
fix: add role UUID field (#9)
jhoward-lm Mar 3, 2025
8d5a2d6
refactor: implement role endpoint methods (#10)
jhoward-lm Mar 3, 2025
463e496
Improve coverage of portfolio ACL checks in REST API endpoints
nscuro Feb 20, 2025
b69b14e
Bump org.wiremock:wiremock from 3.12.0 to 3.12.1
dependabot[bot] Mar 3, 2025
4b8e859
refactor: implement adding/removing users to/from roles (#13)
jhoward-lm Mar 4, 2025
8ea9f2c
refactor: remove description field
ashearin Mar 4, 2025
578ce5d
remove tostring bug, update role serialVersionID
ashearin Mar 10, 2025
e54b52c
add getunassignedprojects to role dao.java, getunassignedprojects to …
ashearin Mar 12, 2025
e8ee4b3
addRoleToUser working
ashearin Mar 14, 2025
b584ef5
refactor: flatten user role join tables (#14)
jhoward-lm Mar 17, 2025
8bf2100
update getunassignedprojects dao query
ashearin Mar 17, 2025
6a5eabb
working getUserRoles and associated mapper/methods/queries, draft rem…
ashearin Mar 19, 2025
bd4f63a
alter getuserUnassignedProjects to not return 404 if no projects are …
ashearin Mar 19, 2025
ef55e06
refactor: create view of project effective permissions for user (#15)
jhoward-lm Mar 19, 2025
5647be0
code cleanup
ashearin Mar 20, 2025
b5e2149
correct merge issue
ashearin Mar 20, 2025
2d1aed3
Role DAO fixes (#16)
jhoward-lm Mar 24, 2025
8215b4c
merge corrections
ashearin Mar 24, 2025
3ba1891
merge corrections
ashearin Mar 25, 2025
ffd4ffc
revert test changes
ashearin Mar 27, 2025
db673de
feat: get user project permissions (wip) (#11)
lmphil Mar 29, 2025
7b11522
Revert "feat: get user project permissions (wip) (#11)" (#17)
ashearin Mar 29, 2025
8e64369
convert roleprojectrequest to record, remove logging, dev change
ashearin Mar 31, 2025
a519fdf
temporary changelog fixes
ashearin Apr 1, 2025
7f7b4ce
refactor: add triggers to update effective permissions table with rol…
jhoward-lm Apr 1, 2025
56b0ff4
refactor: add no content response to retrieveUserProjects
ashearin Apr 3, 2025
e2117c3
refactor: synchronize project roles instead of teams
jhoward-lm Apr 14, 2025
6a72a4d
chore: rebase cleanup
jhoward-lm Apr 16, 2025
ea10653
Merge branch 'main' of https://github.com/ashearin/hyades-apiserver i…
ashearin Apr 17, 2025
4b2e447
merge cleanup
ashearin Apr 17, 2025
b255fe8
refactor: user/permission resource for bulk put request
emeremikwu-lm Apr 21, 2025
c207fa0
refactor: Update User/Permission resource test
emeremikwu-lm Apr 21, 2025
320ac6d
Merge branch 'bulk-request-permissions-teams' of https://www.github.c…
ashearin Apr 21, 2025
edc7c4a
merge fixes
ashearin Apr 21, 2025
c88f6f7
Merge branch 'main' of https://github.com/DependencyTrack/hyades-apis…
jhoward-lm Apr 22, 2025
08fcb04
FE: Expand Gitlab integration page to include sbom push options
alamb-lm Apr 22, 2025
ebb4213
Merge branch 'main' into add-roles-model
ashearin Apr 23, 2025
932ee5a
fix defaultobjectgenerator merge conflicts
ashearin Apr 23, 2025
162f2f9
remove duplicate changeset
ashearin Apr 23, 2025
b69f7a8
Merge branch 'main' of https://github.com/ashearin/hyades-apiserver i…
ashearin Apr 24, 2025
1cbd68d
Merge branch 'add-roles-model' of https://github.com/ashearin/hyades-…
jhoward-lm Apr 25, 2025
ac517dd
refactor: pull changes from Alpine PR
jhoward-lm Apr 25, 2025
0b2af0d
Update ConfigPropertyConstants.java
alamb-lm Apr 28, 2025
b7a095b
Merge branch 'main' of https://github.com/ashearin/hyades-apiserver i…
ashearin Apr 28, 2025
1579965
Update ConfigPropertyConstants.java
alamb-lm Apr 28, 2025
a7071ab
Update createRole API to create a new role with permissions (#22)
alamb-lm Apr 30, 2025
d4be44f
Merge branch 'main' of https://github.com/ashearin/hyades-apiserver i…
ashearin May 5, 2025
0542d36
Merge branch 'add-roles-model' of https://github.com/ashearin/hyades-…
ashearin May 5, 2025
4b91b83
remove role permissions
ashearin May 5, 2025
3fdc943
Merge branch 'add-roles-model' of https://github.com/ashearin/hyades-…
jhoward-lm May 5, 2025
d70f18b
chore: remove unused imports
jhoward-lm May 5, 2025
3c53938
chore: remove unused imports
jhoward-lm May 5, 2025
4594838
Merge branch 'main' of https://github.com/ashearin/hyades-apiserver i…
ashearin May 6, 2025
7883cba
Merge branch 'add-roles-model' of https://github.com/ashearin/hyades-…
jhoward-lm May 6, 2025
c3db2fe
Merge branch 'gitlab-integration' of https://github.com/jhoward-lm/hy…
jhoward-lm May 6, 2025
4b9465e
remove OBE files
ashearin May 7, 2025
c7f5456
test: add RoleResource unit tests (#20)
lmphil May 7, 2025
b4429b0
test: add unit tests for RoleQueryManager class (#19)
lmphil May 7, 2025
8b0e265
Merge branch 'main' of https://github.com/DependencyTrack/hyades-apis…
jhoward-lm May 8, 2025
479285e
refactor: consolidate user tables
jhoward-lm May 9, 2025
d7fab40
fix: unique constraint on USERS_PROJECTS_ROLES
jhoward-lm May 12, 2025
7baf327
Merge branch 'main' of https://github.com/DependencyTrack/hyades-apis…
jhoward-lm May 12, 2025
02f45f1
fix: unique constraint to unique index
jhoward-lm May 12, 2025
ee87d1e
Merge pull request #23 from jhoward-lm/roles-consolidate-user-tables
jhoward-lm May 12, 2025
5164efa
Merge branch 'add-roles-model' of https://github.com/ashearin/hyades-…
jhoward-lm May 12, 2025
f2b6854
fix: add conflict clause to DAO method
jhoward-lm May 12, 2025
ff69661
Merge branch 'add-roles-model' of https://github.com/ashearin/hyades-…
jhoward-lm May 12, 2025
a51c98a
fix: cascade delete user foreign key (#24)
jhoward-lm May 14, 2025
8ab5cc0
Merge branch 'add-roles-model' of https://github.com/ashearin/hyades-…
jhoward-lm May 15, 2025
f92992d
add gitlab integration state toggle
ashearin May 15, 2025
9c14b4d
update Event description
ashearin May 15, 2025
afa7be5
add tests, general cleanup
ashearin May 15, 2025
7dcf484
Apply suggestions from code review
ashearin May 15, 2025
bd3dbd1
chore: cleanup to essentials, add archived default value
ashearin May 15, 2025
a8df3c8
pull in new getPermissionByName
ashearin May 15, 2025
008c39a
chore: rebase cleanup
ashearin May 15, 2025
b059da6
Merge pull request #14 from ashearin/gitlab-integration-state-change
jhoward-lm May 15, 2025
654268c
Merge branch 'gitlab-integration' of https://github.com/jhoward-lm/hy…
jhoward-lm May 15, 2025
dde9fff
chore: includes cleanup
ashearin May 20, 2025
d7b9543
Merge branch 'gitlab-integration-bom-upload' into expand-gitlab-page-api
alamb-lm May 20, 2025
e2f846b
Merge branch 'main' of https://github.com/ashearin/hyades-apiserver i…
ashearin May 20, 2025
f4e880c
chore: regenerate jooq with role tables
jhoward-lm May 20, 2025
8cef6fd
chore: generate deterministic serialVersionUID values
jhoward-lm May 20, 2025
5a807e9
Merge branch 'main' of https://github.com/DependencyTrack/hyades-apis…
jhoward-lm May 20, 2025
4c8fe7e
Merge branch 'add-roles-model' of https://github.com/ashearin/hyades-…
jhoward-lm May 20, 2025
cf75301
Merge pull request #25 from jhoward-lm/regenerate-jooq
ashearin May 21, 2025
36dd72b
Merge pull request #4 from alamb-lm/expand-gitlab-page-api
jhoward-lm May 21, 2025
d5b2819
Merge branch 'add-roles-model' of https://github.com/ashearin/hyades-…
jhoward-lm May 21, 2025
5c65024
Merge branch 'gitlab-integration' of https://github.com/jhoward-lm/hy…
jhoward-lm May 21, 2025
3d60906
Merge branch 'add-roles-model' of https://github.com/ashearin/hyades-…
jhoward-lm Jun 3, 2025
c5d5f79
Merge branch 'gitlab-integration' of https://github.com/jhoward-lm/hy…
jhoward-lm Jun 3, 2025
ee32e75
Merge branch 'main' of https://github.com/DependencyTrack/hyades-apis…
jhoward-lm Jun 4, 2025
1883cdd
Merge branch 'gitlab-integration' of https://github.com/jhoward-lm/hy…
jhoward-lm Jun 4, 2025
4e85b1e
refactor: create default team for GitLab users (#6)
jhoward-lm Jun 5, 2025
eb9351d
Add GitLab Key Constant (#5)
jmayer-lm Jun 5, 2025
94d3545
tests: add additional gitlab integration unit tests, codacy cleanup (#7)
ashearin Jun 5, 2025
c544c11
refactor: enable portfolio access control on integration enable (#8)
jhoward-lm Jun 9, 2025
0fa5c8a
Update GitLabClientTest.java (#10)
ashearin Jun 9, 2025
9684571
fix: OIDC group unique constraint violation error
jhoward-lm Jun 12, 2025
8704dd8
Roles bulk (#9)
emeremikwu-lm Jun 18, 2025
148911c
fix: add error checking into graphql query (#11)
ashearin Jun 18, 2025
4ab49b2
Merge branch 'main' of https://github.com/DependencyTrack/hyades-apis…
jhoward-lm Jun 19, 2025
3ecc535
fix: duplicate user error on sso (#13)
emeremikwu-lm Jul 7, 2025
f60656d
feat: add functionality to upload a sbom from GitLab (#12)
alamb-lm Jul 9, 2025
36ca30e
Merge branch 'main' of https://github.com/DependencyTrack/hyades-apis…
jhoward-lm Jul 9, 2025
5343d95
fix project creation error handling in BomResource (#14)
alamb-lm Jul 9, 2025
aba8f51
tests: update gitlab statechanger tests (#15)
ashearin Jul 14, 2025
318432a
Merge branch 'main' of github.com:DependencyTrack/hyades-apiserver in…
nscuro Jul 27, 2025
7dc5a45
Merge pull request #17 from DependencyTrack/gitlab-integration-bom-up…
jhoward-lm Jul 28, 2025
de1fb9c
chore: address PR comments
jhoward-lm Jul 28, 2025
da87531
refactor: update GitLab JWT verification to use configurable issuer U…
emeremikwu-lm Jul 28, 2025
bd81710
fix: remove unused import (#19)
ashearin Jul 28, 2025
acc0764
fix: add null check for access level field in gitlab token (#18)
ashearin Jul 29, 2025
df911e4
chore: address PR comments
jhoward-lm Jul 31, 2025
2b5a16a
Merge branch 'main' of https://github.com/DependencyTrack/hyades-apis…
jhoward-lm Jul 31, 2025
310fbd1
fix: add missing import
jhoward-lm Jul 31, 2025
7b88d22
fix: project-scoped permissions for role defaults
jhoward-lm Aug 1, 2025
57edd11
fix: user subclass field population
jhoward-lm Aug 1, 2025
3fe52d7
Merge branch 'main' of https://github.com/lmco/hyades-apiserver into …
jwienold413145 Oct 8, 2025
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 @@ -39,6 +39,7 @@
import alpine.security.ApiKeyGenerator;
import org.datanucleus.store.rdbms.query.JDOQLQuery;

import javax.jdo.Extent;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import java.security.Principal;
Expand Down Expand Up @@ -343,6 +344,20 @@ public OidcUser addUserToTeams(final OidcUser user, final List<String> teamNames
});
}

/**
* Returns a complete list of all subclasses extending User.class, in ascending order by username.
* @return a list of all Users
* @since 1.0.0
*/
public PaginatedResult getAllUsers() {
final Query<User> query = pm.newQuery(User.class).orderBy("username ASC");
final PaginatedResult result = execute(query);

pm.refreshAll(result.getObjects());

return result;
}

/**
* Retrieves an LdapUser containing the specified username. If the username
* does not exist, returns null.
Expand Down Expand Up @@ -546,6 +561,22 @@ public User getUser(String username) {
return executeAndCloseUnique(query);
}

/**
* Resolves a type of User.
* @param cls the class of the principal to retrieve
* @param username the username of the principal to retrieve
* @return a User if found, null if not found
* @since 1.0.0
*/
public <T extends User> T getUser(String username, Class<T> cls) {
final Query<T> query = pm.newQuery(cls)
.filter("username == :username")
.setNamedParameters(Map.of("username", username))
.extension(JDOQLQuery.EXTENSION_CANDIDATE_DONT_RESTRICT_DISCRIMINATOR, true);

return (T) executeAndCloseUnique(query);
}

/**
* Creates a new Team with the specified name. If createApiKey is true,
* then {@link #createApiKey} is invoked and a cryptographically secure
Expand All @@ -561,7 +592,7 @@ public Team createTeam(final String name, final boolean createApiKey) {
}

/**
* Creates a new Team with the specified name.
* Creates a new {@link Team} with the specified name.
* @param name The name of the team
* @return a Team
* @since 3.2.0
Expand All @@ -570,7 +601,22 @@ public Team createTeam(final String name) {
return callInTransaction(() -> {
final var team = new Team();
team.setName(name);
//todo assign permissions
pm.makePersistent(team);
return team;
});
}

/**
* Creates a new {@link Team} with the specified name and initial {@link Permission}s.
* @param name The name of the team
* @return a Team
* @since 5.6.0
*/
public Team createTeam(final String name, final List<Permission> permissions) {
return callInTransaction(() -> {
final var team = new Team();
team.setName(name);
team.setPermissions(permissions);
pm.makePersistent(team);
return team;
});
Expand Down
4 changes: 2 additions & 2 deletions alpine/alpine-model/src/main/java/alpine/model/LdapUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
*/
@PersistenceCapable
@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE)
@Discriminator(value = "LDAP")
@Discriminator("LDAP")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder(value = { "username", "dn", "email", "teams", "permissions" })
@JsonPropertyOrder({ "username", "dn", "email", "teams", "permissions" })
public class LdapUser extends User {

private static final long serialVersionUID = 261924579887470488L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
*/
@PersistenceCapable
@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE)
@Discriminator(value = "MANAGED")
@Discriminator("MANAGED")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder(value = {
@JsonPropertyOrder({
"username",
"lastPasswordChange",
"fullname",
Expand Down
4 changes: 2 additions & 2 deletions alpine/alpine-model/src/main/java/alpine/model/OidcUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
*/
@PersistenceCapable
@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE)
@Discriminator(value = "OIDC")
@Discriminator("OIDC")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder(value = { "username", "subjectIdentifier", "email", "teams", "permissions" })
@JsonPropertyOrder({ "username", "subjectIdentifier", "email", "teams", "permissions" })
public class OidcUser extends User {

private static final long serialVersionUID = -6852825148699565269L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import org.dependencytrack.tasks.EpssMirrorTask;
import org.dependencytrack.tasks.FortifySscUploadTask;
import org.dependencytrack.tasks.GitHubAdvisoryMirrorTask;
import org.dependencytrack.tasks.GitLabIntegrationStateTask;
import org.dependencytrack.tasks.GitLabSyncTask;
import org.dependencytrack.tasks.IntegrityAnalysisTask;
import org.dependencytrack.tasks.IntegrityMetaInitializerTask;
import org.dependencytrack.tasks.InternalComponentIdentificationTask;
Expand Down Expand Up @@ -96,6 +98,8 @@ public void contextInitialized(final ServletContextEvent event) {
EVENT_SERVICE.subscribe(VexUploadEvent.class, VexUploadProcessingTask.class);
EVENT_SERVICE.subscribe(LdapSyncEvent.class, LdapSyncTaskWrapper.class);
EVENT_SERVICE.subscribe(GitHubAdvisoryMirrorEvent.class, GitHubAdvisoryMirrorTask.class);
EVENT_SERVICE.subscribe(GitLabIntegrationStateEvent.class, GitLabIntegrationStateTask.class);
EVENT_SERVICE.subscribe(GitLabSyncEvent.class, GitLabSyncTask.class);
EVENT_SERVICE.subscribe(OsvMirrorEvent.class, OsvMirrorTask.class);
EVENT_SERVICE.subscribe(ProjectVulnerabilityAnalysisEvent.class, VulnerabilityAnalysisTask.class);
EVENT_SERVICE.subscribe(PortfolioVulnerabilityAnalysisEvent.class, VulnerabilityAnalysisTask.class);
Expand Down Expand Up @@ -143,6 +147,8 @@ public void contextDestroyed(final ServletContextEvent event) {
EVENT_SERVICE.unsubscribe(VexUploadProcessingTask.class);
EVENT_SERVICE.unsubscribe(LdapSyncTaskWrapper.class);
EVENT_SERVICE.unsubscribe(GitHubAdvisoryMirrorTask.class);
EVENT_SERVICE.unsubscribe(GitLabIntegrationStateTask.class);
EVENT_SERVICE.unsubscribe(GitLabSyncTask.class);
EVENT_SERVICE.unsubscribe(OsvMirrorTask.class);
EVENT_SERVICE.unsubscribe(VulnerabilityAnalysisTask.class);
EVENT_SERVICE.unsubscribe(RepositoryMetaAnalysisTask.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* This file is part of Dependency-Track.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) OWASP Foundation. All Rights Reserved.
*/
package org.dependencytrack.event;

import alpine.event.framework.Event;

/**
* Defines an event used to start a state change task for the GitLab Integration.
*
* @author Allen Shearin
*/
public class GitLabIntegrationStateEvent implements Event {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* This file is part of Dependency-Track.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) OWASP Foundation. All Rights Reserved.
*/
package org.dependencytrack.event;

import alpine.event.framework.Event;
import alpine.model.OidcUser;

/**
* Defines an event used to start a sync task of current user's GitLab groups.
*
* @author Jonathan Howard
*/
public class GitLabSyncEvent implements Event {

private String accessToken;
private OidcUser user;

public GitLabSyncEvent() {

}

public GitLabSyncEvent(final String accessToken, final OidcUser user) {
this.accessToken = accessToken;
this.user = user;
}

public String getAccessToken() {
return accessToken;
}

public void setAccessToken(final String accessToken) {
this.accessToken = accessToken;
}

public OidcUser getUser() {
return user;
}

public void setUser(OidcUser user) {
this.user = user;
}

@Override
public String toString() {
return "%s{accessToken=%s, user=%s}".formatted(getClass().getSimpleName(), accessToken, user);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* This file is part of Dependency-Track.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) OWASP Foundation. All Rights Reserved.
*/
package org.dependencytrack.integrations;

import org.dependencytrack.persistence.QueryManager;

public interface PermissionsSyncer extends IntegrationPoint {

boolean isEnabled();

void setQueryManager(QueryManager qm);

void synchronize();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* This file is part of Dependency-Track.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) OWASP Foundation. All Rights Reserved.
*/
package org.dependencytrack.integrations.gitlab;

import alpine.Config;
import alpine.event.framework.Event;
import alpine.model.OidcUser;
import alpine.server.auth.DefaultOidcAuthenticationCustomizer;
import alpine.server.auth.OidcProfile;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

import org.dependencytrack.event.GitLabSyncEvent;
import org.dependencytrack.persistence.QueryManager;

import com.nimbusds.openid.connect.sdk.claims.ClaimsSet;
import com.nimbusds.openid.connect.sdk.claims.UserInfo;
import net.minidev.json.JSONObject;

public class GitLabAuthenticationCustomizer extends DefaultOidcAuthenticationCustomizer {

@Override
public OidcProfile createProfile(ClaimsSet claimsSet) {
final String teamsClaimName = Config.getInstance().getProperty(Config.AlpineKey.OIDC_TEAMS_CLAIM);
String usernameClaimName = Config.getInstance().getProperty(Config.AlpineKey.OIDC_USERNAME_CLAIM);
final var profile = new OidcProfile();

if (claimsSet.getStringClaim("user_login") != null)
usernameClaimName = "user_login";

profile.setSubject(Objects.requireNonNullElse(claimsSet.getStringClaim("user_id"),
claimsSet.getStringClaim(UserInfo.SUB_CLAIM_NAME)));
profile.setUsername(claimsSet.getStringClaim(usernameClaimName));
profile.setEmail(Objects.requireNonNullElse(claimsSet.getStringClaim("user_email"),
claimsSet.getStringClaim(UserInfo.EMAIL_CLAIM_NAME)));

JSONObject claimsObj = claimsSet.toJSONObject();
claimsObj.remove(UserInfo.EMAIL_CLAIM_NAME);
claimsObj.remove(UserInfo.SUB_CLAIM_NAME);
claimsObj.remove(teamsClaimName);
claimsObj.remove(usernameClaimName);

profile.setCustomValues(claimsObj);

return profile;
}

@Override
public OidcUser onAuthenticationSuccess(OidcUser user, OidcProfile profile, String idToken, String accessToken) {
try (final QueryManager qm = new QueryManager()) {
final List<String> groups = Objects.requireNonNullElse(profile.getGroups(), Collections.emptyList());

groups.stream()
.filter(Objects::nonNull)
.filter(group -> qm.getOidcGroup(group) == null)
.forEach(qm::createOidcGroup);
}

Event.dispatch(new GitLabSyncEvent(accessToken, user));

return user;
}

}
Loading