Skip to content

Commit

Permalink
fix: Avoid duplicate headers (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreyfourmis authored Jan 24, 2024
1 parent bd494eb commit d461384
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,17 @@ public abstract class AbstractAdminResource<T extends AdminAuth> {
public AbstractAdminResource(KeycloakSession session) {
this.session = session;
this.realm = session.getContext().getRealm();
setup();
this.setup();
}

protected AbstractAdminResource(AbstractAdminResource<T> parent) {
this.session = parent.session;
this.realm = parent.realm;
this.auth = parent.auth;
this.adminEvent = parent.adminEvent;
this.user = parent.user;
this.entityManager = parent.entityManager;
this.tenantProvider = parent.tenantProvider;
}

private void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public class TenantInvitationsResource extends AbstractAdminResource<TenantAdmin

private final TenantModel tenant;

public TenantInvitationsResource(KeycloakSession session, TenantModel tenant) {
super(session);
public TenantInvitationsResource(AbstractAdminResource<TenantAdminAuth> parent, TenantModel tenant) {
super(parent);
this.tenant = tenant;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class TenantMembershipsResource extends AbstractAdminResource<TenantAdmin

private final TenantModel tenant;

public TenantMembershipsResource(KeycloakSession session, TenantModel tenant) {
super(session);
public TenantMembershipsResource(AbstractAdminResource<TenantAdminAuth> parent, TenantModel tenant) {
super(parent);
this.tenant = tenant;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class TenantResource extends AbstractAdminResource<TenantAdminAuth> {

private final TenantModel tenant;

public TenantResource(KeycloakSession session, TenantModel tenant) {
super(session);
public TenantResource(AbstractAdminResource<TenantAdminAuth> parent, TenantModel tenant) {
super(parent);
this.tenant = tenant;
}

Expand All @@ -39,11 +39,11 @@ public void deleteTenant() {

@Path("invitations")
public TenantInvitationsResource invitations() {
return new TenantInvitationsResource(session, tenant);
return new TenantInvitationsResource(this, tenant);
}

@Path("memberships")
public TenantMembershipsResource memberships() {
return new TenantMembershipsResource(session, tenant);
return new TenantMembershipsResource(this, tenant);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public TenantResource getTenantResource(@PathParam("tenantId") String tenantId)
if (!auth.isTenantAdmin(model)) {
throw new NotAuthorizedException(String.format("Insufficient permission to access %s", tenantId));
} else {
return new TenantResource(session, model);
return new TenantResource(this, model);
}
}
}

0 comments on commit d461384

Please sign in to comment.