Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/maven/org.webjars-swagger-ui-5.…
Browse files Browse the repository at this point in the history
…10.3
  • Loading branch information
Christian-B authored May 1, 2024
2 parents e987e9f + d34bb69 commit 047d542
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 148 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3.13.0
uses: actions/setup-java@v4.0.0
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3.13.0
uses: actions/setup-java@v4.0.0
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
Expand All @@ -93,7 +93,7 @@ jobs:
continue-on-error: true
- name: Upload Build (JDK 11 only)
if: matrix.java == 11
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: spinnaker-exe.jar
path: SpiNNaker-front-end/target/spinnaker-exe.jar
Expand All @@ -114,7 +114,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3.13.0
uses: actions/setup-java@v4.0.0
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
Expand All @@ -135,7 +135,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v3.13.0
uses: actions/setup-java@v4.0.0
with:
distribution: 'zulu'
java-version: 11
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ env:
jobs:
analyze:
permissions:
actions: read
contents: write
security-events: write
name: Analyze
runs-on: ubuntu-latest
timeout-minutes: 15
Expand All @@ -70,7 +74,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -79,7 +83,7 @@ jobs:
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Set up right Java version: https://github.com/github/codeql-action/issues/825
- uses: actions/setup-java@v3.13.0
- uses: actions/setup-java@v4.0.0
with:
java-version: ${{ matrix.version }}
distribution: zulu
Expand All @@ -93,7 +97,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -107,4 +111,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
6 changes: 4 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ env:
jobs:
build:
permissions:
contents: write
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
Expand All @@ -46,7 +48,7 @@ jobs:
key: ${{ runner.os }}-node-${{ hashFiles('SpiNNaker-allocserv/pom.xml') }}
restore-keys: ${{ runner.os }}-node-
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3.13.0
uses: actions/setup-java@v4.0.0
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
Expand All @@ -70,7 +72,7 @@ jobs:
touch $SITE_DIR/.nojekyll
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4.4.3
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
branch: gh-pages
folder: ${{ env.SITE_DIR }}
Expand Down
9 changes: 7 additions & 2 deletions SpiNNaker-allocserv/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ limitations under the License.
<id>make-project-output-directory</id>
<phase>initialize</phase>
<configuration>
<tasks>
<target>
<mkdir dir="${project.build.directory}/generated-resources"/>
</tasks>
</target>
</configuration>
<goals>
<goal>run</goal>
Expand Down Expand Up @@ -507,6 +507,11 @@ limitations under the License.
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<description>A board allocation service for SpiNNaker.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,10 @@ private Allocations allocate(Connection conn) {
continue;
}
var handled = task.allocate(sql);
// If we handled it, delete the request
if (handled.size() > 0) {
sql.delete.call(task.id);
}
allocations.addAll(task.jobId, handled);
log.debug("allocate for {} (job {}): {}", task.id,
task.jobId, handled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package uk.ac.manchester.spinnaker.alloc.security;

import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.beans.factory.config.BeanDefinition.ROLE_APPLICATION;
import static org.springframework.beans.factory.config.BeanDefinition.ROLE_SUPPORT;
Expand Down Expand Up @@ -61,12 +60,7 @@
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
import org.springframework.security.core.authority.mapping.SimpleAuthorityMapper;
import org.springframework.security.oauth2.client.InMemoryOAuth2AuthorizedClientService;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientService;
import org.springframework.security.oauth2.client.http.OAuth2ErrorResponseErrorHandler;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository;
import org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository;
import org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal;
import org.springframework.security.oauth2.core.oidc.OidcIdToken;
import org.springframework.security.oauth2.core.oidc.OidcUserInfo;
Expand All @@ -82,7 +76,6 @@

import uk.ac.manchester.spinnaker.alloc.ServiceConfig.URLPathMaker;
import uk.ac.manchester.spinnaker.alloc.SpallocProperties.AuthProperties;
import uk.ac.manchester.spinnaker.alloc.SpallocProperties.OpenIDProperties;
import uk.ac.manchester.spinnaker.utils.UsedInJavadocOnly;

/**
Expand Down Expand Up @@ -256,32 +249,6 @@ private void defineAPILoginRules(HttpSecurity http) throws Exception {
}
}

@Bean
public ClientRegistrationRepository clientRegistrationRepository() {
OpenIDProperties props = properties.getOpenid();
List<ClientRegistration> registrations = List.of(
ClientRegistration.withRegistrationId(props.getRegistrationId())
.clientId(props.getId())
.clientSecret(props.getSecret())
.authorizationGrantType(props.getAuthGrantType())
.authorizationUri(props.getAuth())
.tokenUri(props.getToken())
.userInfoUri(props.getUserinfo())
.jwkSetUri(props.getJwkSet())
.issuerUri(props.getIssuer())
.scope(props.getScopes())
.redirectUri(props.getRedirect())
.build());
return new InMemoryClientRegistrationRepository(registrations);
}

@Bean
public OAuth2AuthorizedClientService authorizedClientService() {

return new InMemoryOAuth2AuthorizedClientService(
clientRegistrationRepository());
}

/**
* How we handle the mechanics of login within the web UI.
*
Expand All @@ -302,9 +269,6 @@ private void defineWebUILoginRules(HttpSecurity http) throws Exception {
*/
http.oauth2Login().loginPage(loginUrl)
.loginProcessingUrl(oidcPath("login/code/*"))
.clientRegistrationRepository(
clientRegistrationRepository())
.authorizedClientService(authorizedClientService())
.authorizationEndpoint().baseUri(oidcPath("auth")).and()
.defaultSuccessUrl(rootPage, true)
.failureUrl(loginUrl + "?error=true").userInfoEndpoint()
Expand Down Expand Up @@ -408,7 +372,8 @@ private Map<String, Object> userinfo(String token) {
}
}

private static final class Formatter implements LogFormatter {
private final class Formatter implements LogFormatter {

@Override
public String formatResponse(ClientHttpResponse response)
throws IOException {
Expand All @@ -420,9 +385,11 @@ public String formatResponse(ClientHttpResponse response)
@Override
public String formatRequest(HttpRequest request, byte[] body) {
return String.format(
"%s Request to %s:\n Headers: %s\n Body: %s",
"%s Request to %s:\n"
+ " Headers: %s\n"
+ " Body: %s",
request.getMethod(), request.getURI(), request.getHeaders(),
new String(body, ISO_8859_1)); // A "safe" encoding
new String(body));
}
}

Expand Down
34 changes: 19 additions & 15 deletions SpiNNaker-allocserv/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,18 +271,22 @@ spring:
config:
activate:
on-profile: default
# security:
# oauth2:
# client:
# registration:
# hbp-ebrains:
# client-id: ${spalloc.auth.openid.id}
# client-secret: ${spalloc.auth.openid.secret}
# # Repeated from spalloc.auth.openid.scopes, but can't share!
# scope: [ openid, profile, roles, email, team, group ]
# authorization-grant-type: authorization_code
# redirect-uri: https://{baseHost}{basePort}{basePath}/system/perform_oidc/{action}/code/{registrationId}
# provider:
# hbp-ebrains:
# issuer-uri: ${spalloc.auth.openid.issuer}
# user-name-attribute: preferred_username
security:
oauth2:
client:
registration:
hbp-ebrains:
client-id: ${spalloc.auth.openid.id}
client-secret: ${spalloc.auth.openid.secret}
# Repeated from spalloc.auth.openid.scopes, but can't share!
scope: [ openid, profile, roles, email, team, group ]
authorization-grant-type: ${spalloc.auth.openid.auth-grant-type}
redirect-uri: ${spalloc.auth.openid.redirect}
provider:
hbp-ebrains:
# issuer-uri: ${spalloc.auth.openid.issuer}
authorization-uri: ${spalloc.auth.openid.auth}
token-uri: ${spalloc.auth.openid.token}
user-info-uri: ${spalloc.auth.openid.userinfo}
jwk-set-uri: ${spalloc.auth.openid.jwk-set}
user-name-attribute: preferred_username
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ spalloc:
performance-log: true
performance-threshold: 1e2
datasource:
jdbc-url: jdbc:tc:mysql:8:///;databaseName=spalloc?user=root&password=test
jdbc-url: jdbc:tc:mysql:8.2.0:///;databaseName=spalloc?user=root&password=test
historical-data:
datasource:
jdbc-url: jdbc:tc:mysql:8:///;databaseName=spallochistory?user=root&password=test
jdbc-url: jdbc:tc:mysql:8.2.0:///;databaseName=spallochistory?user=root&password=test
4 changes: 2 additions & 2 deletions SpiNNaker-nmpiserv/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ limitations under the License.
<id>make-project-output-directory</id>
<phase>initialize</phase>
<configuration>
<tasks>
<target>
<mkdir dir="${project.build.directory}/generated-resources"/>
</tasks>
</target>
</configuration>
<goals>
<goal>run</goal>
Expand Down
Loading

0 comments on commit 047d542

Please sign in to comment.