WebSphere Tutorial · WebSphere Liberty · Lesson 10 of 23

Security in Liberty

Authentication and authorisation in Liberty: user registries, application security roles, TLS keystores, and single sign-on options.

Members can save this page, take notes and track progress. See membership · Sign in

Pieces of Liberty security

  • appSecurity-5.0 turns on Jakarta Security; applications declare roles and protected URLs.
  • A user registry: basicRegistry for tests, ldapRegistry for corporate directories, or federation.
  • Role bindings map application roles to users or groups in <application-bnd>.
  • TLS with transportSecurity-1.0, a <keyStore> for the server's certificate and a truststore for outbound calls.
  • Single sign-on with LTPA tokens between Liberty servers, or modern options: openidConnectClient-1.0 (log in through an identity provider) and mpJwt-2.1 (accept JWTs on APIs).
<featureManager>
  <feature>appSecurity-5.0</feature>
  <feature>transportSecurity-1.0</feature>
  <feature>mpJwt-2.1</feature>
</featureManager>
<ldapRegistry host="ldap.example.com" port="636" sslEnabled="true" baseDN="dc=example,dc=com" ldapType="Microsoft Active Directory"
              bindDN="${env.LDAP_BIND_DN}" bindPassword="${env.LDAP_BIND_PASSWORD}"/>
<keyStore id="defaultKeyStore" location="key.p12" password="${env.KEYSTORE_PASSWORD}"/>
Role bindings deciding access to protected URLsTry it yourself
bindings = {"admin": {"group:billing-admins"}, "viewer": {"group:billing-admins", "group:finance"}}
user_groups = {"ana": {"group:finance"}, "raj": {"group:billing-admins"}, "zoe": set()}
constraints = {"/billing/report": "viewer", "/billing/refund": "admin"}

for user, groups in user_groups.items():
    for url, role in constraints.items():
        allowed = bool(groups & bindings[role])
        print(f"{user:4} {url:16} needs {role:6} -> {'allowed' if allowed else '403 Forbidden'}")

Output

ana  /billing/report  needs viewer -> allowed
ana  /billing/refund  needs admin  -> 403 Forbidden
raj  /billing/report  needs viewer -> allowed
raj  /billing/refund  needs admin  -> allowed
zoe  /billing/report  needs viewer -> 403 Forbidden
zoe  /billing/refund  needs admin  -> 403 Forbidden

Test yourself

Which Liberty feature lets REST APIs accept JSON Web Tokens?

  1. jdbc
  2. mpJwt
  3. mpHealth
  4. jsonb
Show answer

Answer: mpJwt

MicroProfile JWT authenticates requests with signed JWTs.

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake