【发布时间】:2018-11-20 13:50:30
【问题描述】:
我正在尝试使用 JWT 和 Spring Boot 2 实现 OAuth2 服务器。互联网上有一些很好的示例,例如 this 或 this。他们正在使用一些带有一堆字段的数据库表(oauth_client_details、oauth_client_token、oauth_code、oauth_approvals、ClientDetails)。其中一些很容易理解,而另一些则不然。我在任何地方都找不到关于需要哪些表和字段以及它们的含义的解释:
create table oauth_client_details ( /*Stores client details*/
client_id VARCHAR(255) PRIMARY KEY,
resource_ids VARCHAR(255), /*Q1: is this comma separated list of resources?*/
client_secret VARCHAR(255),
scope VARCHAR(255),
authorized_grant_types VARCHAR(255),
web_server_redirect_uri VARCHAR(255),
authorities VARCHAR(255), /*Q2: what it this for?*/
access_token_validity INTEGER, /*Q3: Is this the validity period in seconds?*/
refresh_token_validity INTEGER,
additional_information VARCHAR(4096), /*Q4: Can I omit this field if I don't need any additional information?*/
autoapprove VARCHAR(255) /*Q5: What does this mean?*/
);
create table if not exists oauth_client_token ( /*Q6: What is this table for?*/
token_id VARCHAR(255),
token LONGVARBINARY,
authentication_id VARCHAR(255) PRIMARY KEY,
user_name VARCHAR(255),
client_id VARCHAR(255)
);
create table if not exists oauth_access_token ( /*Q7: Do I need this table if I use JWT?*/
token_id VARCHAR(255),
token LONGVARBINARY,
authentication_id VARCHAR(255) PRIMARY KEY,
user_name VARCHAR(255),
client_id VARCHAR(255),
authentication LONGVARBINARY,
refresh_token VARCHAR(255)
);
create table if not exists oauth_refresh_token ( /*Q8: Do I need this table if I use JWT?*/
token_id VARCHAR(255),
token LONGVARBINARY,
authentication LONGVARBINARY
);
create table if not exists oauth_code (
code VARCHAR(255), authentication LONGVARBINARY
);
create table if not exists oauth_approvals ( /*Q9: What it this for?*/
userId VARCHAR(255),
clientId VARCHAR(255),
scope VARCHAR(255),
status VARCHAR(10),
expiresAt TIMESTAMP,
lastModifiedAt TIMESTAMP
);
create table if not exists ClientDetails ( /*Q10: Yet another client details???*/
appId VARCHAR(255) PRIMARY KEY,
resourceIds VARCHAR(255),
appSecret VARCHAR(255),
scope VARCHAR(255),
grantTypes VARCHAR(255),
redirectUrl VARCHAR(255),
authorities VARCHAR(255),
access_token_validity INTEGER,
refresh_token_validity INTEGER,
additionalInformation VARCHAR(4096),
autoApproveScopes VARCHAR(255)
);
【问题讨论】:
-
我也在寻找一些解释。 Spring 是否有上述模式的官方文档?我搜索并找不到任何东西。有人可以帮忙吗?
-
很遗憾,我找不到 Spring 的任何官方文档,我不相信它存在。
标签: spring spring-boot spring-security oauth-2.0 spring-security-oauth2