Skip to content

Commit 21a847d

Browse files
committed
Merge branch 'release/20.1.0'
2 parents 353795b + 448229a commit 21a847d

65 files changed

Lines changed: 2952 additions & 646 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@
22

33
We follow the CalVer (https://calver.org/) versioning scheme: YY.MINOR.MICRO.
44

5+
20.1.0 (11-05-2020)
6+
===================
7+
8+
OSF CAS second release with FE re-design, BE improvements and DevOps updates
9+
10+
* FE
11+
* Refactored styles to be consistent with both OSF and oldCAS
12+
* Rewrote how authentication delegation info is retrieved and used
13+
* Improved the behavior of inline error messages in login forms
14+
* Added new / Rewrote existing authentication exception pages
15+
* Improved UI / UX in responsive mode and on various screen dimensions
16+
17+
* BE
18+
* Implemented a dedicated OSF CAS login context and a couple of pre-login
19+
check actions to support ORCiD login and institution SSO
20+
* Implemented ORCiD sign-up auto-redirect for OSF
21+
22+
* DevOps
23+
* Updated tomcat server to work with its enclosing Shibboleth server
24+
* Separated staging / production and local configurations
25+
* Rewrote cas.properties into a helm charts template
26+
* Improved build / run / reload for local development
27+
28+
* Other
29+
* Replaced Apereo branding with COS / OSF in multiple places
30+
531
20.0.0 (09-02-2020)
632
===================
733

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ RUN cd cas-overlay \
1717

1818
FROM adoptopenjdk/openjdk11:alpine-jre AS cas
1919

20-
LABEL "Organization"="Apereo"
21-
LABEL "Description"="Apereo CAS"
20+
LABEL "Organization"="Center for Open Science"
21+
LABEL "Description"="OSF CAS"
2222

2323
RUN cd / \
2424
&& mkdir -p /etc/cas/config \
@@ -32,7 +32,7 @@ COPY etc/cas/services/ /etc/cas/services/
3232
COPY etc/cas/saml/ /etc/cas/saml/
3333
COPY --from=overlay cas-overlay/build/libs/cas.war cas-overlay/
3434

35-
EXPOSE 8080 8443
35+
EXPOSE 8080
3636

3737
ENV PATH $PATH:$JAVA_HOME/bin:.
3838

Dockerfile-local

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
FROM adoptopenjdk/openjdk11:alpine-slim AS overlay
2+
3+
RUN mkdir -p cas-overlay
4+
COPY ./src cas-overlay/src/
5+
COPY ./gradle/ cas-overlay/gradle/
6+
COPY ./gradlew ./settings.gradle ./build.gradle ./gradle.properties /cas-overlay/
7+
8+
RUN mkdir -p ~/.gradle \
9+
&& echo "org.gradle.daemon=false" >> ~/.gradle/gradle.properties \
10+
&& echo "org.gradle.configureondemand=true" >> ~/.gradle/gradle.properties \
11+
&& cd cas-overlay \
12+
&& chmod 750 ./gradlew \
13+
&& ./gradlew --version;
14+
15+
RUN cd cas-overlay && ./gradlew clean build --parallel --no-daemon;
16+
# The build process above in docker may takes a long time depending on your local resources. This OK if you only use
17+
# CAS by building it once. For local development, building in local shell or with your IDE such as IntelliJ is much
18+
# faster. Afterwards, simply comment out the above "RUN" command and enable the following "COPY" one. In fact, this
19+
# stage can be skipped if you have the WAR built locally. Just need run the second stage with a modified WAR source.
20+
# COPY ./build cas-overlay/build/
21+
22+
FROM adoptopenjdk/openjdk11:alpine-jre AS cas
23+
24+
LABEL "Organization"="Center for Open Science"
25+
LABEL "Description"="OSF CAS"
26+
27+
RUN cd / \
28+
&& mkdir -p /etc/cas/config \
29+
&& mkdir -p /etc/cas/services \
30+
&& mkdir -p /etc/cas/saml \
31+
&& mkdir -p cas-overlay;
32+
33+
COPY etc/cas/ /etc/cas/
34+
35+
COPY etc/cas/config/ /etc/cas/config/
36+
# Use "cas-local.properties" and "log4j2-local.xml" for local development
37+
RUN rm etc/cas/config/cas.properties
38+
COPY etc/cas/config/local/cas-local.properties etc/cas/config/cas.properties
39+
COPY etc/cas/config/local/log4j2-local.xml etc/cas/config/log4j2.xml
40+
RUN rm -r etc/cas/config/local
41+
42+
COPY etc/cas/services/ /etc/cas/services/
43+
# Use registered services defined in "local/services" for local development
44+
COPY etc/cas/services/local/* /etc/cas/services/
45+
RUN rm -r etc/cas/services/local/
46+
47+
COPY etc/cas/saml/ /etc/cas/saml/
48+
49+
COPY --from=overlay cas-overlay/build/libs/cas.war cas-overlay/
50+
51+
EXPOSE 8080
52+
53+
ENV PATH $PATH:$JAVA_HOME/bin:.
54+
55+
WORKDIR cas-overlay
56+
ENTRYPOINT ["java", "-server", "-noverify", "-Xmx2048M", "-jar", "cas.war"]

README.md

Lines changed: 72 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ OSF CAS is the centralized authentication and authorization service for the [OSF
1818
* OSF username and password login
1919
* OSF username and verification key login
2020
* OSF two-factor authentication
21-
* **WIP** - Delegated authentication
21+
* Delegated authentication
22+
* ORCiD login
23+
* **WIP** - CAS client: supports CAS protocol based institution SSO
24+
* **WIP** - SAML service provider: supports SAML protocol based institution SSO
2225
* **TBI** - OAuth authorization server for OSF
23-
* **TBI** - SAML service provider
2426

2527
# Implementations
2628

@@ -37,32 +39,84 @@ A legacy version can be found at [CAS Overlay](https://github.com/CenterForOpenS
3739
- PostgreSQL `9.6`
3840
- JDK `11`
3941

40-
# Build and Run OSF CAS
42+
# Configure, Build and Run OSF CAS
43+
44+
It is recommended to use the provided scripts to [build](https://github.com/CenterForOpenScience/osf-cas/blob/develop/docker-build.sh) and [run](https://github.com/CenterForOpenScience/osf-cas/blob/develop/docker-run.sh) CAS. Refer to Apereo's [README.md](https://github.com/apereo/cas-overlay-template/tree/6.2#cas-overlay-template-) for more options.
45+
46+
Use [`cas.properties`](https://github.com/CenterForOpenScience/osf-cas/blob/develop/etc/cas/config/cas.properties) and [`Dockerfile`](https://github.com/CenterForOpenScience/osf-cas/blob/develop/Dockerfile) to configure staging and production servers. Use [`cas-local.properties`](https://github.com/CenterForOpenScience/osf-cas/blob/develop/etc/cas/config/local/cas-local.properties) and [`Dockerfile-local`](https://github.com/CenterForOpenScience/osf-cas/blob/develop/Dockerfile-local) for local development. To accelerate developing OSF CAS, use the [reload](https://github.com/CenterForOpenScience/osf-cas/blob/develop/docker-reload.sh) script to rebuild, reconfigure and restart the running container.
4147

4248
## OSF
4349

4450
OSF CAS requires a working OSF running locally. Refer to OSF's [README-docker-compose.md](https://github.com/CenterForOpenScience/osf.io/blob/develop/README-docker-compose.md) for how to set up and run OSF with `docker-compose`. Must disable `fakeCAS` to free port `8080`.
4551

46-
In `cas.propeties`, global JDBC settings can be found [here](https://github.com/cslzchen/osf-cas/blob/21bb277cc38b3364fd67a632c0bc7b7a6ffc9efd/etc/cas/config/cas.properties#L69-L73) and JPA specific settings can be found [here](https://github.com/cslzchen/osf-cas/blob/21bb277cc38b3364fd67a632c0bc7b7a6ffc9efd/etc/cas/config/cas.properties#L54-L60).
52+
### OSF DB
53+
54+
More specifically, CAS requires a running OSF PostgreSQL database to handle authentication for OSF. Use the authentication handler's [JPA settings](https://github.com/CenterForOpenScience/osf-cas/blob/790cac1ac5a19754c67d6ea1f53afc26e1809d23/etc/cas/config/cas.properties#L70-L86) for [`OsfPostgresAuthenticationHandler`](https://github.com/CenterForOpenScience/osf-cas/blob/develop/src/main/java/io/cos/cas/osf/authentication/handler/support/OsfPostgresAuthenticationHandler.java) to connect to and access OSF DB.
55+
56+
Here is an example for local development. Use `192.168.168.167` to access host outside the docker container. Set `readOnly=true` since CAS only needs read-only access ([Principle of Least Privilege](https://en.wikipedia.org/wiki/Principle_of_least_privilege)).
57+
58+
```yaml
59+
# In `cas.properties` or `cas-local.properties`
60+
61+
cas.authn.osf-postgres.jpa.user=postgres
62+
cas.authn.osf-postgres.jpa.password=
63+
cas.authn.osf-postgres.jpa.driver-class=org.postgresql.Driver
64+
cas.authn.osf-postgres.jpa.url=jdbc:postgresql://192.168.168.167:5432/osf?targetServerType=master&readOnly=true
65+
cas.authn.osf-postgres.jpa.dialect=io.cos.cas.osf.hibernate.dialect.OsfPostgresDialect
66+
```
4767

4868
## CAS DB
4969

50-
OSF CAS is configured to use the [JPA Ticket Registry](https://apereo.github.io/cas/6.2.x/ticketing/Configuring-Ticketing-Components.html#ticket-registry) for durable ticket storage. Thus, a relational database is required. Set up a `PostgreSQL@9.6` server and update *JPA Ticket Registry* [settings](https://github.com/cslzchen/osf-cas/blob/21bb277cc38b3364fd67a632c0bc7b7a6ffc9efd/etc/cas/config/cas.properties#L65-L113) in `cas.propeties` accordingly. Must use a port other than the already occupied `5432`.
70+
The implementation of OSF CAS uses the [JPA Ticket Registry](https://apereo.github.io/cas/6.2.x/ticketing/Configuring-Ticketing-Components.html#ticket-registry) for durable ticket storage and thus requires a relational database. Set up a `PostgreSQL@9.6` server and review [JPA Ticket Registry settings](https://github.com/CenterForOpenScience/osf-cas/blob/790cac1ac5a19754c67d6ea1f53afc26e1809d23/etc/cas/config/cas.properties#L90-L138). In most cases, only [Database connections](https://github.com/CenterForOpenScience/osf-cas/blob/790cac1ac5a19754c67d6ea1f53afc26e1809d23/etc/cas/config/cas.properties#L104-L108) need to be updated. In addition, [JDBC settings](https://github.com/CenterForOpenScience/osf-cas/blob/790cac1ac5a19754c67d6ea1f53afc26e1809d23/etc/cas/config/cas.properties#L96-L98) can be adjusted if necessary.
71+
72+
Here is an example for local development. Use `192.168.168.167` to access host outside the docker container. Use the port `54321` since the default `5432` one has been used by OSF DB. Update `pg_hba.conf` to grant proper access permission depending on the setup.
73+
74+
```yaml
75+
# In `cas.properties` or `cas-local.properties`
76+
77+
cas.ticket.registry.jpa.user=longzechen
78+
cas.ticket.registry.jpa.password=
79+
cas.ticket.registry.jpa.driver-class=org.postgresql.Driver
80+
cas.ticket.registry.jpa.url=jdbc:postgresql://192.168.168.167:54321/osf-cas?targetServerType=master
81+
cas.ticket.registry.jpa.dialect=org.hibernate.dialect.PostgreSQL95Dialect
82+
```
83+
84+
```yaml
85+
# In `pg_hba.conf`
86+
87+
# TYPE DATABASE USER ADDRESS METHOD
88+
host osf-cas longzechen 192.168.168.167/24 trust
89+
```
5190

5291
## Signing and Encryption Keys
5392

54-
Refer to [settings](https://github.com/cslzchen/osf-cas/blob/21bb277cc38b3364fd67a632c0bc7b7a6ffc9efd/etc/cas/config/cas.properties#L117-L133) in `cas.properties` for signing and encrypting client session and ticket granting cookie.
93+
Refer to [signing and encryption settings](https://github.com/CenterForOpenScience/osf-cas/blob/790cac1ac5a19754c67d6ea1f53afc26e1809d23/etc/cas/config/cas.properties#L142-L158) in `cas.properties` for signing and encrypting client sessions and ticket granting cookies. Use the following default keys **for local development only**.
94+
95+
```yaml
96+
# In `cas-local.properties`
97+
98+
cas.webflow.crypto.signing.key=7okipSDHBKuZL2n66cfYU4OH1Z_BRYkmEJazc29hzhXCXbRvws7Hv4_hEVd4E2osMrgIEdykzV2hAVD9CCQpJw
99+
cas.webflow.crypto.encryption.key=1A9hLtxA-Es-hbQsfxqxxw
100+
101+
cas.tgc.crypto.signing.key=_WTRQmXGuq-mx2pTjNCXuX5971-e8KOCFOa27Mh5I3oBobYSzyUrLS9rfSiXQQDolJrJrWv7jURID1vtouznHg
102+
cas.tgc.crypto.encryption.key=dcjD5PIfrcqGM8tv4_FGubcay-DbqKPPoz9xQ3IHQi0
103+
```
55104

56105
## Authentication Delegation
57106

58107
### ORCiD Login
59108

60-
Set up a developer app at [ORCiD](https://orcid.org/developer-tools) with `http://localhost:8080/login` and `http://192.168.168.167:8080/login` as *redirect URIs*. Update
61-
`cas.authn.pac4j.orcid.id` and `cas.authn.pac4j.orcid.secret` in `cas.properties` [settings](https://github.com/cslzchen/osf-cas/blob/21bb277cc38b3364fd67a632c0bc7b7a6ffc9efd/etc/cas/config/cas.properties#L186-L192).
109+
To enable ORCiD login, update `cas.authn.pac4j.orcid.id` and `cas.authn.pac4j.orcid.secret` [here](https://github.com/CenterForOpenScience/osf-cas/blob/790cac1ac5a19754c67d6ea1f53afc26e1809d23/etc/cas/config/cas.properties#L212-L213) in delegation settings accordingly.
110+
111+
For local development, set up a developer app at [ORCiD](https://orcid.org/developer-tools) with `http://localhost:8080/login` and `http://192.168.168.167:8080/login` as *redirect URIs*.
112+
113+
### Institution Login
62114

63-
### `fakeCAS` Login
115+
( ... WIP ... )
64116

65-
With OSF CAS running locally as the authentication server for OSF, `fakeCAS` can be configured to serve as an identity provider. Simply update `fakecas` in OSF's [docker-compose.yaml](https://github.com/CenterForOpenScience/osf.io/blob/dc87c86b2afb7ad4e801b23c6428e3d2169e3e36/docker-compose.yml#L235-L247) to listen on port 8081.
117+
#### `fakeCAS` Login (Local Development Only)
118+
119+
With OSF CAS running locally as the authentication server for OSF, the previously disabled `fakeCAS` can be re-configured to serve as an identity provider. Simply update `fakecas` in OSF's [docker-compose.yaml](https://github.com/CenterForOpenScience/osf.io/blob/dc87c86b2afb7ad4e801b23c6428e3d2169e3e36/docker-compose.yml#L235-L247) to listen on port `8081`.
66120

67121
```
68122
fakecas:
@@ -76,15 +130,15 @@ fakecas:
76130
stdin_open: true
77131
```
78132

79-
Related settings in `cas.propeties` can be found [here](https://github.com/cslzchen/osf-cas/blob/21bb277cc38b3364fd67a632c0bc7b7a6ffc9efd/etc/cas/config/cas.properties#L196-L199).
133+
Related `cas.propeties` settings can be found [here](https://github.com/CenterForOpenScience/osf-cas/blob/790cac1ac5a19754c67d6ea1f53afc26e1809d23/etc/cas/config/local/cas-local.properties#L192-L235).
80134

81-
## Build and Run
135+
```yaml
136+
# In `cas-local.properties`
82137

83-
It is recommended to use the `Dockerfile` and the provided scripts to build and run CAS.
138+
cas.authn.osf-postgres.institution-clients[2]=${cas.authn.pac4j.cas[2].client-name}
84139

85-
```bash
86-
./docker-build.sh
87-
./docker-run.sh
140+
cas.authn.pac4j.cas[2].login-url=http://192.168.168.167:8081/login
141+
cas.authn.pac4j.cas[2].client-name=fakecas
142+
cas.authn.pac4j.cas[2].protocol=CAS30
143+
cas.authn.pac4j.cas[2].callback-url-type=QUERY_PARAMETER
88144
```
89-
90-
Refer to Apereo's [README.md](https://github.com/apereo/cas-overlay-template/tree/6.2#cas-overlay-template-) for more options.

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ dependencies {
115115
// JPA Ticket Registry
116116
implementation "org.apereo.cas:cas-server-support-jpa-ticket-registry:${project.'cas.version'}"
117117

118+
// Tomcat Catalina
119+
implementation "org.apache.tomcat:tomcat-catalina:${springBootTomcatVersion}"
120+
118121
// Hibernate
119122
implementation "org.hibernate:hibernate-core:${hibernateCoreVersion}"
120123

docker-reload.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# Rebuild locally and replace the WAR
4+
./gradlew clean build
5+
docker cp ./build/libs/cas.war cas:/cas-overlay
6+
7+
# Sync configuration files
8+
docker exec -d cas sh -c "rm -rf /etc/cas/config/*"
9+
docker cp ./etc/cas/config/local/cas-local.properties cas:/etc/cas/config/cas.properties
10+
docker cp ./etc/cas/config/local/log4j2-local.xml cas:/etc/cas/config/log4j2.xml
11+
12+
# Sync JSON registered service files
13+
docker exec -d cas sh -c "rm -rf /etc/cas/services/*"
14+
docker cp ./etc/cas/services/local/. cas:/etc/cas/services
15+
16+
# Restart the container
17+
docker restart cas
18+
docker logs -f --tail 0 cas

docker-run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
docker stop cas > /dev/null 2>&1
44
docker rm cas > /dev/null 2>&1
55
image_tag=(`cat gradle.properties | grep "cas.version" | cut -d= -f2`)
6-
docker run -d -p 8080:8080 -p 8443:8443 --name="cas" apereo/cas:"v${image_tag}"
7-
docker logs -f cas
6+
docker run -d -p 8080:8080 --name="cas" apereo/cas:"v${image_tag}"
7+
docker logs -f cas

0 commit comments

Comments
 (0)