在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):myndocs/kotlin-oauth2-server开源软件地址(OpenSource Url):https://github.com/myndocs/kotlin-oauth2-server开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):Kotlin OAuth2 serverGoalThe goal of this project is to provide a simple OAuth2 library which can be implemented in any framework Configuring the oauth2 server for any framework should be simple and understandable. It encourages to adapt to existing implementations instead the other way around. FrameworksSetupMaven<properties>
<myndocs.oauth.version>0.7.1</myndocs.oauth.version>
</properties>
<dependencies>
<dependency>
<groupId>nl.myndocs</groupId>
<artifactId>oauth2-server-core</artifactId>
<version>${myndocs.oauth.version}</version>
</dependency>
<!-- In memory dependencies -->
<dependency>
<groupId>nl.myndocs</groupId>
<artifactId>oauth2-server-client-inmemory</artifactId>
<version>${myndocs.oauth.version}</version>
</dependency>
<dependency>
<groupId>nl.myndocs</groupId>
<artifactId>oauth2-server-identity-inmemory</artifactId>
<version>${myndocs.oauth.version}</version>
</dependency>
<dependency>
<groupId>nl.myndocs</groupId>
<artifactId>oauth2-server-token-store-inmemory</artifactId>
<version>${myndocs.oauth.version}</version>
</dependency>
</dependencies> Gradledependencies {
implementation "nl.myndocs:oauth2-server-core:$myndocs_oauth_version"
// In memory dependencies
implementation "nl.myndocs:oauth2-server-client-inmemory:$myndocs_oauth_version"
implementation "nl.myndocs:oauth2-server-identity-inmemory:$myndocs_oauth_version"
implementation "nl.myndocs:oauth2-server-token-store-inmemory:$myndocs_oauth_version"
} Framework implementationThe following frameworks are supported: ConfigurationRoutingDefault endpoints are configured:
These values can be overridden: tokenEndpoint = "/custom/token"
authorizationEndpoint = "/custom/authorize"
tokenInfoEndpoint = "/custom/tokeninfo" In memoryIn memory implementations are provided to easily setup the project. IdentityOn the identityService = InMemoryIdentity()
.identity {
username = "foo-1"
password = "bar"
}
.identity {
username = "foo-2"
password = "bar"
} ClientOn the clientService = InMemoryClient()
.client {
clientId = "app1-client"
clientSecret = "testpass"
scopes = setOf("admin")
redirectUris = setOf("https://localhost:8080/callback")
authorizedGrantTypes = setOf(
AuthorizedGrantType.AUTHORIZATION_CODE,
AuthorizedGrantType.PASSWORD,
AuthorizedGrantType.IMPLICIT,
AuthorizedGrantType.REFRESH_TOKEN
)
}
.client {
clientId = "app2-client"
clientSecret = "testpass"
scopes = setOf("user")
redirectUris = setOf("https://localhost:8080/callback")
authorizedGrantTypes = setOf(
AuthorizedGrantType.AUTHORIZATION_CODE
)
} Token storeThe tokenStore = InMemoryTokenStore() ConvertersAccess token converterBy default accessTokenConverter = UUIDAccessTokenConverter(1800) To use JWT include the following dependency: <dependency>
<groupId>nl.myndocs</groupId>
<artifactId>oauth2-server-jwt</artifactId>
<version>${myndocs.oauth.version}</version>
</dependency> This uses auth0 jwt. To configure: accessTokenConverter = JwtAccessTokenConverter(
algorithm = Algorithm.HMAC256("test123"), // mandatory
accessTokenExpireInSeconds = 1800, // optional default 3600
jwtBuilder = DefaultJwtBuilder // optional uses DefaultJwtBuilder by default
) Refresh token converterBy default refreshTokenConverter = UUIDRefreshTokenConverter(1800) To use JWT include the following dependency: <dependency>
<groupId>nl.myndocs</groupId>
<artifactId>oauth2-server-jwt</artifactId>
<version>${myndocs.oauth.version}</version>
</dependency> This uses auth0 jwt. To configure: refreshTokenConverter = JwtRefreshTokenConverter(
algorithm = Algorithm.HMAC256("test123"), // mandatory
refreshTokenExpireInSeconds = 1800, // optional default 86400
jwtBuilder = DefaultJwtBuilder // optional uses DefaultJwtBuilder by default
) Code token converterBy default codeTokenConverter = UUIDCodeTokenConverter(120) |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论