Skip to content

Commit

Permalink
Add nyckeln under dörrmattan
Browse files Browse the repository at this point in the history
  • Loading branch information
foodelevator committed Feb 22, 2024
1 parent 49e38b9 commit 468dc5d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
14 changes: 12 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ services:
JDBC_DATABASE_URL: "jdbc:postgresql://db:5432/postgres"
JDBC_DATABASE_USERNAME: postgres
JDBC_DATABASE_PASSWORD: calypso
APPLICATION_URL: http://localhost.datasektionen.se:3000
env_file: .env
APPLICATION_URL: http://localhost:3000
LOGIN_FRONTEND_URL: http://localhost:7002/
LOGIN_API_URL: http://login:7002/
LOGIN_KEY: asdf
ports:
- "3000:8080"
login:
image: ghcr.io/datasektionen/nyckeln-under-dorrmattan
ports:
- 7002:7002
environment:
# Since we're using the real pls, it's nice to use some user with a lot of priveleges. Putting
# mine here since I'm d-sys at the time of writing.
KTH_ID: mathm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public DAuthEntryPoint(Config config) {
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException)
throws IOException {
response.sendRedirect(config.getLoginUrl() + "/login?callback=" +
response.sendRedirect(config.getLoginFrontendUrl() + "/login?callback=" +
config.getBaseUrl() + "/auth/verify?token=");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public DAuthUserDetailsService(Config config) {
public UserDetails loadUserDetails(PreAuthenticatedAuthenticationToken token) throws UsernameNotFoundException {
// Required variables
var t = token.getPrincipal().toString();
var url = config.getLoginUrl() + "/verify/" + t + ".json?api_key=" + config.getLoginApiKey();
var url = config.getLoginApiUrl() + "/verify/" + t + ".json?api_key=" + config.getLoginApiKey();

var headers = new HttpHeaders();
headers.set("User-Agent", "Spring Framework/Java " + System.getProperty("java.version"));
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/se/datasektionen/calypso/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
public class Config {
private final String baseUrl;
private final String loginApiKey;
private final String loginUrl;
private final String loginFrontendUrl;
private final String loginApiUrl;

public Config(
@Value("${APPLICATION_URL}") String baseUrl,
@Value("${LOGIN_KEY}") String loginApiKey,
@Value("${LOGIN_URL:https://login.datasektionen.se}") String loginUrl
@Value("${LOGIN_FRONTEND_URL:https://login.datasektionen.se}") String loginFrontendUrl,
@Value("${LOGIN_API_URL:https://login.datasektionen.se}") String loginApiUrl
) {
this.baseUrl = baseUrl;
this.loginApiKey = loginApiKey;
this.loginUrl = loginUrl;
this.loginFrontendUrl = loginFrontendUrl;
this.loginApiUrl = loginApiUrl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@
"description": "API key for login."
},
{
"name": "LOGIN_URL",
"name": "LOGIN_FRONTEND_URL",
"type": "java.lang.String",
"description": "URL to login."
"description": "URL to login frontend."
},
{
"name": "LOGIN_API_URL",
"type": "java.lang.String",
"description": "URL to login api."
}
]
}

0 comments on commit 468dc5d

Please sign in to comment.