Skip to content

Remove legacy "seats" claim #391

@overheadhunter

Description

@overheadhunter

Hub 1.5.0 introduced the "org.cryptomator.hub.entitlements" claim which includes "seats". We still have the non-nested "seats" claim for backwards compatibility.

  • var licensedSeats = jwt.getClaim("seats").asInt(); // TODO eventually replace with "org.cryptomator.hub.entitlements"."seats", see https://github.com/cryptomator/hub/issues/391
  • var entitlements = license.getClaim("org.cryptomator.hub.entitlements").as(HubLicenseEntitlements.class);
    // TODO: eventually "entitlements" claim will be mandatory and this fallback can be removed, see https://github.com/cryptomator/hub/issues/391
    if (entitlements == null) { // legacy (pre 1.5.0) license without "org.cryptomator.hub.entitlements" claim:
    return HubLicenseEntitlements.create().withSeats(license.getClaim("seats").asLong());
    } else {
    return entitlements;
    }
  • private static final String[] REQUIRED_CLAIMS = {"seats"}; // TODO: eventually phase out "seats" claim in favor of "org.cryptomator.hub.entitlements"."seats", see https://github.com/cryptomator/hub/issues/391
  • @Test
    @DisplayName("validate valid legacy token (pre org.cryptomator.hub.entitlements)")
    // TODO: eventually remove this test when legacy tokens are no longer supported, see https://github.com/cryptomator/hub/issues/391
    void testValidateValidToken() {
    var jwt = validator.validate(VALID_LEGACY_TOKEN, "42");
    Assertions.assertEquals("ES512", jwt.getAlgorithm());
    Assertions.assertEquals("42", jwt.getId());
    Assertions.assertEquals("Skymatic", jwt.getIssuer());
    Assertions.assertEquals("Cryptomator Hub", jwt.getAudience().get(0));
    Assertions.assertEquals("hub@cryptomator.org", jwt.getSubject());
    Assertions.assertEquals(5, jwt.getClaim("seats").asInt());
    Assertions.assertEquals(253402214400l, jwt.getExpiresAt().getTime() / 1000);
    Assertions.assertEquals("http://localhost:8787/hub/subscription?hub_id=42", jwt.getClaim("refreshUrl").asString());
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions