Arc*_*hie 7 spring spring-security oauth-2.0 spring-boot spring-security-oauth2
我正在尝试使用 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)
);
Run Code Online (Sandbox Code Playgroud)
对于 JWT 令牌,不需要oauth_access_token&oauth_refresh_token表。检查实现以JwtTokenStore获取更多信息。
哪些表是必需的,完全取决于您使用的OAuth 授权类型。如果您使用授权类型oauth_code,oauth_approvals则需要像&这样的表Authorization code。
scope和之间不同authorities,检查OAuth Scope vs Authorities
| 归档时间: |
|
| 查看次数: |
8549 次 |
| 最近记录: |