IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method...

23
JWT Access Control David Schultz IT Pro Conf 2019 Multi-service security for IceCube

Transcript of IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method...

Page 1: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

JWT Access Control

David SchultzIT Pro Conf 2019

Multi-service security for IceCube

Page 2: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Outline

≻ What problem are we trying to solve?

≻ JSON Web Tokens

≻ Service implementation

≻ Real world deployment2

Page 3: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Problems

1. Several services need similar access control

╌ Shared identity provider (IDP)╌ Ideally, single sign-on

3

Page 4: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Problems

1. Several services need similar access control

2. Services may need to communicate with other services on behalf of a user

4

Page 5: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Problems

1. Several services need similar access control

2. Services may need to communicate with other services on behalf of a user

3. Need both interactive and non-interactive mechanisms╌ Save identity to file for use in batch processing

5

Page 6: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Problems

1. Several services need similar access control

2. Services may need to communicate with other services on behalf of a user

3. Need both interactive and non-interactive mechanisms

Tokens!6

Page 7: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

What is a token?

Generically, a token is a bit of authorization data

“With this token, I give you power to do X”

Specifically for JWT:

JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.

7

Page 8: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

What does JWT look like?

8

https://jwt.io/

Page 9: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

A basic JWT service

9

Page 10: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

A basic JWT service

10

1. Make request to web service

Page 11: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

A basic JWT service

11

1. Make request to web service

2. Redirect to JWT service

Page 12: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

A basic JWT service

12

1. Make request to web service

2. Redirect to JWT service

3. Do OAuth 2 three-legged authorization

Page 13: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

A basic JWT service

13

1. Make request to web service

2. Redirect to JWT service

3. Do OAuth 2 three-legged authorization

4. Return a token to the web service

Page 14: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Multi-service authorization

╶ Two services both using JWT tokens

╌ Must request specific auth from token service

╌ Must check that auth is in the token

14

Page 15: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Multi-service authorization

╶ Backend service B

╌ Frontend service A must request both A and B auth in the same token

╌ Token from user can then be used in request to service B

15

Page 16: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Long-lived tokens

OAuth 2 has a concept of access and refresh tokens╶ All tokens up to now have been access tokens

╌ Short-lived, on order of minutes or hours╌ Limits damage if stolen

╶ Refresh tokens can help create new tokens with same capabilities╌ Hand JWT server a refresh token, ask for a new refresh token or an

access token╌ Does not get refreshed forever, but can extend token lifetime up to

days / weeks without user intervention

╶ While our JWT tokens aren’t OAuth 2, the concept is copied over16

Page 17: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Non-interactive token usage

Service that submits batch jobs╶ Interactive submission of jobs - human initiates auth

╌ Refresh tokens keep the auth alive until the job needs it╌ Access tokens provide short-lived access inside the job

17

refresh

access

Page 18: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Notes on scaling

Q: Why do you need tokens? Can’t you contact the auth server for each request?

Yes, but that is a scaling bottleneck

With tokens, as long as the token is valid it keeps working without having to re-authorize it

╶ This matters when you get 100s of requests per second, per service

18

Page 19: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Security Considerations

JWT is publicly readable╶ Do not put secrets in them╶ These are only for access controls and fairly public data

╌ Example: userid, name, access

Use public/private keys instead of a shared key╶ Only the JWT server should have the private key╶ Services use the public key to verify the token

19

Page 20: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Extra credit: revoking tokens

Most JWT systems do not have a revocation mechanism, and rely on token expiration

IceCube’s token service has built-in revocation of tokens

Advantages:- Can revoke both individual access and all refresh tokens- With two steps, can do immediate revocation from a service

Disadvantages:- A lot more bookkeeping

20

Page 21: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Extra credit: revoking tokens

╶ Each token is registered with the revocation service╶ JWT services periodically download new revocation lists

╌ Automatically at service restart, for two-step immediate revocation╶ Revocation list is checked at JWT validation

21

Page 22: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Deployment notes

IceCube’s token service is deployed in Kubernetes

╶ 1 pod for the token service + revocation list╶ 1 pod per auth

╌ 3 auths so far, more to come as services get migrated╶ Each pod gets its own dns address and https cert

A “test” token server in a container exists to test services╶ Approves all requests without checking auth

22

Page 23: IT Pro Conf 2019 David Schultz · JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. 7. What does JWT look like?

Conclusions

IceCube has a JWT token service╶ Uses Oauth 2 to talk to identity provider (LDAP in this case)╶ Uses cookies to remember identity for 24 hours╶ Access tokens with multi-service auth╶ Refresh tokens for longer, non-interactive access

Initial deployment with a few services

Working on integrating more services in the coming months

23