api keys: add IP whitelist and API permission system.
Add the ability to restrict API keys so that they can only be used with certain IP addresses or certain API endpoints. Restricting your key is useful to limit damage in case it gets leaked or stolen. For example, if your key is on a remote server and it gets hacked, or if you accidentally check-in your key to Github. Restricting your key's API permissions is useful if a third-party app or script wants your key, but you don't want to give full access to your account. If you're an app or userscript developer, and your app needs an API key from the user, you should only request a key with the minimum permissions needed by your app. If you have a privileged account, and you have scripts running under your account, you are highly encouraged to restrict your key to limit damage in case your key gets leaked or stolen.
This commit is contained in:
@@ -454,7 +454,13 @@ CREATE TABLE public.api_keys (
|
||||
user_id integer NOT NULL,
|
||||
key character varying NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL
|
||||
updated_at timestamp without time zone NOT NULL,
|
||||
name character varying DEFAULT ''::character varying NOT NULL,
|
||||
permissions character varying[] DEFAULT '{}'::character varying[] NOT NULL,
|
||||
permitted_ip_addresses inet[] DEFAULT '{}'::inet[] NOT NULL,
|
||||
uses integer DEFAULT 0 NOT NULL,
|
||||
last_used_at timestamp without time zone,
|
||||
last_ip_address inet
|
||||
);
|
||||
|
||||
|
||||
@@ -7957,6 +7963,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20210123112752'),
|
||||
('20210127000201'),
|
||||
('20210127012303'),
|
||||
('20210214095121');
|
||||
('20210214095121'),
|
||||
('20210214101614');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user