-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
736cbf4
commit 0f8c930
Showing
3 changed files
with
94 additions
and
41 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
server/src/main/java/org/eclipse/openvsx/security/DefaultAuthUser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 Ericsson and others | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.openvsx.security; | ||
|
||
import org.springframework.security.oauth2.core.user.OAuth2User; | ||
|
||
public class DefaultAuthUser implements AuthUser { | ||
|
||
final String authId; | ||
final String avatarUrl; | ||
final String email; | ||
final String fullName; | ||
final String loginName; | ||
final String providerId; | ||
final String providerUrl; | ||
|
||
public DefaultAuthUser(String providerId, OAuth2User oauth2User) { | ||
authId = oauth2User.getName(); | ||
avatarUrl = oauth2User.getAttribute("avatar_url"); | ||
email = oauth2User.getAttribute("email"); | ||
fullName = oauth2User.getAttribute("name"); | ||
loginName = oauth2User.getAttribute("login"); | ||
this.providerId = providerId; | ||
providerUrl = oauth2User.getAttribute("html_url"); | ||
} | ||
|
||
@Override | ||
public String getAuthId() { | ||
return authId; | ||
} | ||
|
||
@Override | ||
public String getAvatarUrl() { | ||
return avatarUrl; | ||
} | ||
|
||
@Override | ||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
@Override | ||
public String getFullName() { | ||
return fullName; | ||
} | ||
|
||
@Override | ||
public String getLoginName() { | ||
return loginName; | ||
} | ||
|
||
@Override | ||
public String getProviderId() { | ||
return providerId; | ||
} | ||
|
||
@Override | ||
public String getProviderUrl() { | ||
return providerUrl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters