-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(oauth2): add Spring Security OAuth2 documentation #1677
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f0216cf
feat(oauth2): add Spring Security OAuth2 documentation
danielkelemen 107b50f
add more sections & details
danielkelemen 67782bf
add cross-links & details
danielkelemen 493730d
logging
danielkelemen 44432e9
example
danielkelemen 931167e
add configs to main page & some fixes
danielkelemen 9904282
Update content/user-guide/spring-boot-integration/spring-security.md
danielkelemen ea45c5a
Update content/user-guide/spring-boot-integration/spring-security.md
danielkelemen 345fb43
Update content/user-guide/spring-boot-integration/spring-security.md
danielkelemen 2ede3d0
Update content/user-guide/spring-boot-integration/spring-security.md
danielkelemen 26b072f
Update content/user-guide/spring-boot-integration/spring-security.md
danielkelemen 13c161a
review feedback
danielkelemen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
180 changes: 180 additions & 0 deletions
180
content/user-guide/spring-boot-integration/spring-security.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
--- | ||
|
||
title: 'Spring Security OAuth2 Integration' | ||
weight: 80 | ||
|
||
menu: | ||
main: | ||
identifier: "user-guide-spring-security-integration" | ||
parent: "user-guide-spring-boot-integration" | ||
|
||
--- | ||
|
||
|
||
Camunda provides Spring Security OAuth2 integration with the `camunda-bpm-spring-boot-starter-security` library. | ||
This library contains the Spring Security and Spring Security OAuth2 dependencies along with | ||
configuration classes that integrate Spring Security with Camunda Webapp's authentication. | ||
|
||
This is available both for Spring Boot and Camunda Run. | ||
|
||
# Spring Boot | ||
|
||
In order to enable the Spring Security OAuth2 integration in Spring Boot, add the following dependency to your project: | ||
|
||
```xml | ||
<dependency> | ||
<groupId>org.camunda.bpm.springboot</groupId> | ||
<artifactId>camunda-bpm-spring-boot-starter-security</artifactId> | ||
</dependency> | ||
``` | ||
|
||
# Camunda Run | ||
|
||
In order to enable the Spring Security OAuth2 integration in Camunda Run, start Run with an extra `--oauth2` argument: | ||
|
||
```shell | ||
./start.sh --webapps --rest --example --oauth2 | ||
danielkelemen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
# Auto Configuration | ||
|
||
The Camunda integration has two default auto configurations. Depending on the OAuth2 client | ||
registration in the application properties (`spring.security.oauth2.client.registration`) either the | ||
`CamundaSpringSecurityOAuth2AutoConfiguration` or the `CamundaBpmSpringSecurityDisableAutoConfiguration` will be used. | ||
|
||
## OAuth2 Auto Configuration | ||
|
||
|
||
Starts if there is OAuth2 client registration configured. This class configures the Spring | ||
Security filter chain to a permit all mode. | ||
|
||
Spring auto configuration class: {{< javadocref page="org/camunda/bpm/spring/boot/starter/security/oauth2/impl/CamundaSpringSecurityOAuth2AutoConfiguration.html" text="CamundaSpringSecurityOAuth2AutoConfiguration" >}} | ||
|
||
## Disable Auto Configuration | ||
|
||
Starts if there is **no** OAuth2 client registration configured. This class configures the Spring | ||
danielkelemen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Security filter chain to a permit all mode. | ||
|
||
Spring auto configuration class: {{< javadocref page="org/camunda/bpm/spring/boot/starter/security/oauth2/impl/CamundaBpmSpringSecurityDisableAutoConfiguration.html" text="CamundaBpmSpringSecurityDisableAutoConfiguration" >}} | ||
|
||
|
||
# OAuth2 Integration | ||
|
||
Once the Camunda Spring Security OAuth2 integration is active and there is an OAuth2 client | ||
registration configured, the Webapps will use the configured OAuth2 identity provider for authentication. | ||
|
||
For the client registration, please refer to the official Spring Security's [OAuth2 Core Configuration][OAuth2Config] documentation to configure your choice of identity provider. | ||
|
||
Camunda's integration uses the **name** field from Spring Security's principal object for the user | ||
authentication. This needs to match the User ID in Camunda. | ||
|
||
{{< note title="Heads Up!" class="info" >}} | ||
At this stage, OAuth2 is only used for authentication. Meaning, that the user needs to be | ||
also configured with the matching User ID and proper authorizations in Camunda. | ||
|
||
If the user is not available or doesn't have sufficient authorizations, they won't be able to access the Webapps. | ||
{{< /note >}} | ||
|
||
### User Name Mapping | ||
|
||
Spring Security provides an attribute to override the default scope (`sub`) used for the username. | ||
This is the `spring.security.oauth2.client.provider.[providerId].user-name-attribute` from the | ||
above-mentioned [OAuth2 Core Configuration][OAuth2Config]. | ||
|
||
If you wish to use a default attribute (claim) as the username, then make sure to override the `user-name-attribute` in your application properties. | ||
|
||
### Initial User | ||
|
||
In order to create an initial user in your application, you can either use the `camunda.bpm.admin-user` property: | ||
yanavasileva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```yaml | ||
camunda.bpm: | ||
admin-user: | ||
id: demo | ||
password: demo | ||
firstName: Demo | ||
lastName: Demo | ||
``` | ||
|
||
Or the `AdministratorAuthorizationPlugin`, see [The Administrator Authorization Plugin]({{< ref "/user-guide/process-engine/authorization-service.md#the-administrator-authorization-plugin" >}}) documentation for more details. | ||
|
||
|
||
## OAuth2 Identity Provider | ||
|
||
Additionally to the OAuth2 login, Camunda also provides support to use groups from OAuth2. | ||
This is achieved with a custom [identity service]({{< ref "/user-guide/process-engine/identity-service.md" >}}), called {{< javadocref page="org/camunda/bpm/spring/boot/starter/security/oauth2/impl/OAuth2IdentityProvider.html" text="OAuth2IdentityProvider" >}} | ||
danielkelemen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
This is a read-only identity provider that configures user's groups from the [Spring Security's granted authorities][Authorities]. | ||
Additionally, the identity provider also contains the default Camunda Database Identity Service as a fallback. | ||
|
||
TODO add more details | ||
danielkelemen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
In order to activate this, add the following properties: | ||
```yaml | ||
camunda.bpm.oauth2: | ||
danielkelemen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
identity-provider: | ||
enabled: true | ||
``` | ||
|
||
### Authorities mapping | ||
|
||
We also provide a default granted authorities mapper, that can override the Spring Security | ||
authorities, that are populated by default with the scope claim. | ||
|
||
This mapper can be enabled with the `camunda.bpm.oauth2.identity-provider.group-name-attribute` property: | ||
```yaml | ||
camunda.bpm.oauth2: | ||
identity-provider: | ||
enabled: true | ||
group-name-attribute: cognito:groups | ||
``` | ||
|
||
Alternatively, you can also define your own [GrantedAuthoritiesMapper][GrantedAuthoritiesMapper], if you need more customization. | ||
|
||
## Security Recommendations | ||
|
||
If you decide to use OAuth2 for login in Camunda, we highly recommend to consult and implement the current industry recommended security standards. | ||
Additionally, also follow the security recommendations specified by your identity provider. | ||
danielkelemen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Token Lifetime | ||
|
||
As OAuth2 works with the exchange of tokens and tokens are valid until the specified expiration ( | ||
`exp` claim), it is inevitable that in a few cases tokens might outlive the main SSO session. | ||
Meaning, the user might be already logged out but still have valid tokens on other pages. | ||
|
||
In order to minimize the occurrence if this, we recommend the use of short-lived access tokens along with refresh tokens. | ||
|
||
TODO add some links | ||
? https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics | ||
|
||
|
||
## Disabling Auto Configuration | ||
danielkelemen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
If you wish to completely disable Camunda's integration, refer to Spring's [Disabling Specific Auto-configuration Classes][DisableAutoConfig] documentation. | ||
|
||
With the `@EnableAutoConfiguration` annotation: | ||
|
||
```java | ||
@EnableAutoConfiguration(exclude={ | ||
CamundaSpringSecurityOAuth2AutoConfiguration.class, | ||
CamundaBpmSpringSecurityDisableAutoConfiguration.class | ||
}); | ||
``` | ||
|
||
Or in the application properties: | ||
|
||
```yaml | ||
spring: | ||
autoconfigure: | ||
exclude: | ||
- org.camunda.bpm.spring.boot.starter.security.oauth2.CamundaSpringSecurityOAuth2AutoConfiguration | ||
- org.camunda.bpm.spring.boot.starter.security.oauth2.CamundaBpmSpringSecurityDisableAutoConfiguration | ||
``` | ||
|
||
[SpringSecurity]: https://docs.spring.io/spring-security/reference/index.html | ||
[SpringSecurityOAuth2]: https://docs.spring.io/spring-security/reference/servlet/oauth2/index.html | ||
[OAuth2Config]: https://docs.spring.io/spring-security/reference/servlet/oauth2/login/core.html | ||
[Authorities]: https://docs.spring.io/spring-security/reference/servlet/authorization/architecture.html | ||
[GrantedAuthoritiesMapper]: https://docs.spring.io/spring-security/reference/servlet/oauth2/login/advanced.html#oauth2login-advanced-map-authorities | ||
[DisableAutoConfig]: https://docs.spring.io/spring-boot/reference/using/auto-configuration.html#using.auto-configuration.disabling-specific | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Do we need to add anything else on this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few more things about configs, logout, customizing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see anything added on the page? Are any commits missing or?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I mixed the source up, I didn't add anything more here.
I don't think we need more,
--oauth2
flag is specified and linked.