Skip to content

Commit

Permalink
server+webui: use dynamic /login endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-marechal committed Dec 10, 2024
1 parent da3ee40 commit 1abe659
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
10 changes: 10 additions & 0 deletions server/src/main/java/org/eclipse/openvsx/OVSXConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public void setAuth(AuthConfig authConfig) {

public static class AuthConfig {

private String provider = "github";

/**
* Configuration example:
* <pre><code>
Expand All @@ -38,6 +40,14 @@ public static class AuthConfig {
*/
private Map<String, AttributeNames> attributeNames = emptyMap();

public String getProvider() {
return provider;
}

public void setProvider(String provider) {
this.provider = provider;
}

public Map<String, AttributeNames> getAttributeNames() {
return attributeNames;
}
Expand Down
7 changes: 5 additions & 2 deletions server/src/main/java/org/eclipse/openvsx/UserAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,20 @@ public class UserAPI {
private final UserService users;
private final EclipseService eclipse;
private final StorageUtilService storageUtil;
private final OVSXConfig config;

public UserAPI(
RepositoryService repositories,
UserService users,
EclipseService eclipse,
StorageUtilService storageUtil
StorageUtilService storageUtil,
OVSXConfig config
) {
this.repositories = repositories;
this.users = users;
this.eclipse = eclipse;
this.storageUtil = storageUtil;
this.config = config;
}

/**
Expand All @@ -73,7 +76,7 @@ public UserAPI(
path = "/login"
)
public ModelAndView login(ModelMap model) {
return new ModelAndView("redirect:/oauth2/authorization/github", model);
return new ModelAndView("redirect:/oauth2/authorization/" + config.getAuth().getProvider(), model);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion webui/src/extension-registry-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class ExtensionRegistryService {
}

getLoginUrl(): string {
return createAbsoluteURL([this.serverUrl, 'oauth2', 'authorization', 'github']);
return createAbsoluteURL([this.serverUrl, 'login']);
}

getLogoutUrl(): string {
Expand Down

0 comments on commit 1abe659

Please sign in to comment.