Skip to content
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

Remove OAuth Filter #145

Merged
merged 2 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,5 @@ RUN cd jetty-base && java -jar $JETTY_HOME/start.jar --add-module=annotations,se

COPY ./target/jersey-webservice-template-$WS_VERSION.war $JETTY_WEBAPPS_DIR/ROOT.war

ENV OAUTH_ENABLED false

COPY ./Dockerfile-startup.sh /Dockerfile-startup.sh
CMD [ "/Dockerfile-startup.sh" ]
39 changes: 4 additions & 35 deletions docs/docs/configuration.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 7
sidebar_position: 5
title: Configuration
---

Expand All @@ -23,44 +23,15 @@ import TabItem from '@theme/TabItem';
The configurations in this page can be set from several sources in the following order:

1. the [operating system's environment variables]; for instance, an environment variable can be set with
`export OAUTH_ENABLED="true"`
`export DB_URL="jdbc:mysql://db/elide?serverTimezone=UTC"`
2. the [Java system properties]; for example, a Java system property can be set using
`System.setProperty("OAUTH_ENABLED", "true")`
`System.setProperty("DB_URL", "jdbc:mysql://db/elide?serverTimezone=UTC")`
3. a **.properties** file placed under CLASSPATH. This file can be put under `src/main/resources` source directory with
contents, for example, `OAUTH_ENABLED=true`
contents, for example, `DB_URL=jdbc:mysql://db/elide?serverTimezone=UTC`

Note that environment config has higher priority than Java system properties. Java system properties have higher
priority than file based configuration.

OAuth 2
-------

:::info

The following configurations can be placed in the properties file called **src/main/resources/oauth.properties**

:::

- **OAUTH_ENABLED**: Whether or not to enable [OAuthFilter] container request filter.
- **JWKS_URL**: (**Required if `OAUTH_ENABLED` is set to `true`**) A standard [JWKS] URL that, on GET, returns a json
object such as

```json
{
"keys": [
{
"kty": "EC",
"use": "sig",
"kid": "eTERknhur9q8gisdaf_dfrqrgdfsg",
"alg": "ES384",
"crv": "P-384",
"x": "sdfrgHGYF...",
"y": "sdfuUIG&8..."
}
]
}
```

CI/CD
-----

Expand Down Expand Up @@ -101,9 +72,7 @@ The following [GitHub Action Secrets][GitHub Action - How to set up] needs to be

[Java system properties]: https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
[JWT JPA Maven setting tags]: https://github.com/QubitPi/jersey-webservice-template/blob/jpa-elide/settings.xml.example
[JWKS]: https://datatracker.ietf.org/doc/html/rfc7517

[Maven settings file]: https://maven.apache.org/settings.html

[OAuthFilter]: https://qubitpi.github.io/jersey-webservice-template/apidocs/com/qubitpi/ws/jersey/template/web/filters/OAuthFilter.html
[operating system's environment variables]: https://docs.oracle.com/javase/tutorial/essential/environment/env.html
2 changes: 1 addition & 1 deletion docs/docs/elide/_category_.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "JPA through yahoo/elide",
"position": 5,
"position": 4,
"link": {
"type": "generated-index",
"description": "Jersey Webservice Template delegates persistence logics to yahoo/elide"
Expand Down
10 changes: 0 additions & 10 deletions docs/docs/elide/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,6 @@ Compose file:
- (**required**) `MODEL_PACKAGE_NAME` is the package in config JAR that contains all
[elide models](https://elide.io/pages/guide/v7/02-data-model.html). In the example above, we assign the package
`com.mycompany.models` to it
- (optional) `OAUTH_ENABLED` & `JWKS_URL` allow us to turn on OAuth feature in Docker Compose. For example, we might
need it in acceptance tests. The two variables are set in pair:

```bash
export $OAUTH_ENABLED=true
export $JWKS_URL=https://8is478.logto.app/oidc/jwks # this is an example URL :)
```

_Note that OAuth feature is disabled by default in Docker Compose (i.e. OAUTH_ENABLED=false)_

- (optional) `MYSQL_INIT_SCRIPT_PATH` is the path (absolute or relative) to the
[MySQL init script][database init script]. _By default, its value is `./mysql-init.sql`_. This option is very useful
when Docker Compose is running inside Docker (Docker-in-Docker), in which case `MYSQL_INIT_SCRIPT_PATH` is not the
Expand Down
54 changes: 0 additions & 54 deletions docs/docs/elide/img/oauth2-filtering.drawio

This file was deleted.

Binary file removed docs/docs/elide/img/oauth2-filtering.png
Binary file not shown.
51 changes: 0 additions & 51 deletions docs/docs/elide/security.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -410,54 +410,3 @@ public class AdminCheck extends UserCheck {

The `EntityDictionary` must be told to scan for checks (by calling `dictionary.scanForSecurityChecks`). This is done
automatically in Elide at startup.

OAuth 2 Access Token
--------------------

Elide adds a layer of security on its own by validating [OAuth 2 access token] on all incoming request. Each Elide API
request requires a standard `"Authentication": "Bearer <access_token>"` token header:

:::info

The validator is working exclusively for ES384 JWT token and can be turned on by setting **OAUTH_ENABLED** to _true_.
There are 3 ways to do so (with the priority in the following order):

1. Putting an **oauth.properties** file under _src/main/resources_ directory with the following content

```properties
OAUTH_ENABLED=true
```

2. Setting an OS environment variable using, for example, `export OAUTH_ENABLED=true`
3. Define a JVM system property by

```java
System.setProperty("OAUTH_ENABLED", "true");
```

In addition, JWKs URL needs to be set with **JWKS_URL** using the same approach above. The URL should display something
like the following

```json
{
"keys": [
{
"kty": "EC",
"use": "sig",
"kid": "eTERknhur9q8gisdaf_dfrqrgdfsg",
"alg": "ES384",
"crv": "P-384",
"x": "sdfrgHGYF...",
"y": "sdfuUIG&8..."
}
]
}
```

:::

![Error loading oauth2-filtering.png](img/oauth2-filtering.png)

[OAuth 2 access token]: https://www.oauth.com/oauth2-servers/access-tokens/

[source-grammar]: https://github.com/yahoo/elide/blob/master/elide-core/src/main/antlr4/com/yahoo/elide/generated/parsers/Expression.g4#L25
Loading
Loading