ckan / ideas

[DEPRECATED] Use the main CKAN repo Discussions instead:
https://github.com/ckan/ckan/discussions
40 stars 2 forks source link

RFC 0001: Authorization APIs (and JWT) for CKAN #247

Open rufuspollock opened 4 years ago

rufuspollock commented 4 years ago

Zoom Meeting Video: https://drive.google.com/drive/folders/1lhwHnAw7p7DmT_hTzC-2OK-RbnRXjY4n?usp=sharing

tl;dr

Working implementation

https://github.com/datopian/ckanext-authz-service

Overview

Introduction to JWT and tokens (or What's the problem with API Keys?)

Service A, Service B, Permissions Service "P|

graph LR

Client --want to do X, apikey--> A[service A]
A --check api key, permission--> P[Permissions Service]

Client --want to do X, apikey--> B[service B]
B --check api key, permission--> P

Every action on every service is going to hit Service P

Also any compromise in any service compromises your API key! Which is universal, full power token!! (b/c i send my api key to every service ...)

A token setup is INVERSION of CONTROL ...

graph LR

Client --permission request for service A--> P[Permissions Service]
P --token for A--> Client

Client --token--> A[Service A]

Client --permission request for service B--> P[Permissions Service]
P --token for B--> Client
Client --token--> B[Service B]

If i compromise your token for A i have only that ... (scoping)

Also one request to service P and then i can do lots of requests on A ... => high performance, no latency ...

Qu: how does service A know the token is valid? Because P signs it with its public key ...

Use Case

Frontend

When building a decoupled read frontend I want to display edit buttons (or other permissions based UI) to users based on their permissions so that they have a great experience

Cloud Storage

Storage access with a microservice "Storage Access Granter"


sequenceDiagram
  participant browser as Browser/Script
  participant Authz as CKAN Authz Ext
  participant giftless as Storage Access Granter
  participant storage as Cloud Storage

  browser->>browser: Select files to upload
  browser->>Authz: authorize(scopes, API Key)
  Authz->>Authz: check authorization in logic layer
  Authz->>browser: JWT token

  browser->>giftless: request_storage_access(fileinfo, JWT)
  giftless->>browser: signed upload URLs

  browser->>storage: Upload file1.csv
  storage->>browser: File OK

How it works internally

TODO

  sequenceDiagram

  participant client as Client
  participant authorize as authorize()
  participant scopes as Scopes
  participant authziie as Authziie

FAQs

How does this relate to Sergey's work in https://github.com/ckan/ckan/pull/5146/

Sergey's work is somewhat related and somewhat orthogonal. It is primarily about

Bonus