-
Notifications
You must be signed in to change notification settings - Fork 4
Story/cite 217 - It should be possible to create personal access tokens #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
PradnyaC11
wants to merge
29
commits into
develop
Choose a base branch
from
story/CITE-217
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
23822fe
[CITE-217] Adding Access Token
diya17 17dbe63
[CITE-217] Adding user token manager
diya17 6f89887
[CITE-217] Adding create token method for access token
diya17 57f6eea
[CITE-217] Adding CRUD operations
diya17 befbf1d
Extending user access token repository and manager
diya17 ba2c4d1
[CITE-217] Adding Form and controller
diya17 8beb5a3
[CITE-217] Adding controllers
diya17 78d74b9
[CITE-217] : Controllers and views
diya17 d0b037d
[CITE-217] Adding views for details
diya17 24c6348
[CITE-217] Changing endpoints
diya17 8d4de31
[CITE-217] Adding to the header
diya17 abe4e3d
[CITE-217] Making changes to controllers and views
diya17 5c320f3
[CITE-217] Fixing issues with deletion and regeneration
diya17 0086228
[CITE-217] Changing token implementation to implicit token
diya17 163a27c
[CITE-217] Extending Oauthclient manager
diya17 a4047a1
[CITE-217] Changing CRUD to OauthClient
diya17 4a248d6
[CITE-217] Refactoring and changing CRUD class
diya17 5e4088d
[CITE-217] Changing access token generation
diya17 7c617b4
[CITE-217] Adding testcases
diya17 a122954
[CITE-217] : Refactoring
diya17 0f0f5fe
[CITE-217] Update pom
diya17 c7d70e0
[CITE-217] : Update Method
diya17 d648041
Merge branch 'develop' into story/CITE-217
PradnyaC11 27d7271
[CITE-217] Resolved the errors and removed duplicate codes
PradnyaC11 ec9d301
[CITE-217] Seperated manager class for personal oauth
Girik1105 51f7b94
[CITE-217] Created own seperate sub class and removed flag
Girik1105 8096355
[CITE-217] Removed garbage text
Girik1105 14630b3
[CITE-217] Fixed javascript to show tokens after regenration
Girik1105 bbdde80
[CITE-217] Code cleanup
Girik1105 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
10 changes: 10 additions & 0 deletions
10
...ere/src/main/java/edu/asu/diging/citesphere/core/exceptions/CannotFindTokenException.java
This file contains hidden or 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,10 @@ | ||
| package edu.asu.diging.citesphere.core.exceptions; | ||
|
|
||
| public class CannotFindTokenException extends Exception { | ||
|
|
||
| private static final long serialVersionUID = 1L; | ||
|
|
||
| public CannotFindTokenException(String message) { | ||
| super(message); | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
...sphere/src/main/java/edu/asu/diging/citesphere/core/model/oauth/IPersonalAccessToken.java
This file contains hidden or 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,24 @@ | ||
| package edu.asu.diging.citesphere.core.model.oauth; | ||
|
|
||
| import java.time.OffsetDateTime; | ||
|
|
||
| /** | ||
| * Interface representing a personal access token for API access. | ||
| * Personal access tokens allow users to authenticate against the API | ||
| * without going through the OAuth authorization code flow. | ||
| */ | ||
| public interface IPersonalAccessToken { | ||
|
|
||
| String getId(); | ||
|
|
||
| String getName(); | ||
| void setName(String name); | ||
|
|
||
| String getUsername(); | ||
|
|
||
| OffsetDateTime getCreatedAt(); | ||
| void setCreatedAt(OffsetDateTime createdAt); | ||
|
|
||
| boolean isPersonalAccessToken(); | ||
| void setPersonalAccessToken(boolean isPersonalAccessToken); | ||
| } |
This file contains hidden or 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 hidden or 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
15 changes: 15 additions & 0 deletions
15
.../java/edu/asu/diging/citesphere/core/model/oauth/impl/PersonalAccessTokenOAuthClient.java
This file contains hidden or 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,15 @@ | ||
| package edu.asu.diging.citesphere.core.model.oauth.impl; | ||
|
|
||
| import javax.persistence.DiscriminatorValue; | ||
| import javax.persistence.Entity; | ||
|
|
||
| /** | ||
| * Subclass of OAuthClient specifically for personal access tokens. | ||
| * The type itself identifies PAT clients | ||
| */ | ||
| @Entity | ||
| @DiscriminatorValue("PAT") | ||
| public class PersonalAccessTokenOAuthClient extends OAuthClient { | ||
|
|
||
| private static final long serialVersionUID = 1L; | ||
| } |
This file contains hidden or 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 hidden or 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
21 changes: 21 additions & 0 deletions
21
...asu/diging/citesphere/core/repository/oauth/PersonalAccessTokenOAuthClientRepository.java
This file contains hidden or 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,21 @@ | ||
| package edu.asu.diging.citesphere.core.repository.oauth; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import edu.asu.diging.citesphere.core.model.oauth.impl.PersonalAccessTokenOAuthClient; | ||
|
|
||
| /** | ||
| * Repository for personal access token OAuth clients. | ||
| * This repository handles the specialized PAT client subclass. | ||
| */ | ||
| public interface PersonalAccessTokenOAuthClientRepository | ||
| extends JpaRepository<PersonalAccessTokenOAuthClient, String> { | ||
|
|
||
| /** | ||
| * Find a personal access token client by the username of the user who created it. | ||
| * Each user has at most one PAT client. | ||
| */ | ||
| Optional<PersonalAccessTokenOAuthClient> findByCreatedByUsername(String username); | ||
| } |
This file contains hidden or 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
61 changes: 61 additions & 0 deletions
61
...c/main/java/edu/asu/diging/citesphere/core/service/oauth/IPersonalAccessTokenManager.java
This file contains hidden or 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,61 @@ | ||
| package edu.asu.diging.citesphere.core.service.oauth; | ||
|
|
||
| import org.springframework.data.domain.Pageable; | ||
|
|
||
| import edu.asu.diging.citesphere.core.exceptions.CannotFindTokenException; | ||
| import edu.asu.diging.citesphere.core.model.oauth.IPersonalAccessToken; | ||
| import edu.asu.diging.citesphere.user.IUser; | ||
|
|
||
| /** | ||
| * Manager for personal access token operations. | ||
| * Personal access tokens allow users to authenticate against the API | ||
| * without going through the OAuth authorization code flow. | ||
| */ | ||
| public interface IPersonalAccessTokenManager { | ||
|
|
||
| /** | ||
| * Creates a new personal access token for the user. | ||
| * | ||
| * @param name the user-given name for the token | ||
| * @param user the user creating the token | ||
| * @return credentials containing the token ID and token value (shown only once) | ||
| */ | ||
| PersonalAccessTokenCredentials createToken(String name, IUser user); | ||
|
|
||
| /** | ||
| * Gets all personal access tokens for the user. | ||
| * | ||
| * @param user the user whose tokens to retrieve | ||
| * @param pageable pagination information | ||
| * @return paginated result of tokens | ||
| */ | ||
| PersonalAccessTokenResultPage getTokensForUser(IUser user, Pageable pageable); | ||
|
|
||
| /** | ||
| * Deletes a personal access token. | ||
| * | ||
| * @param tokenId the ID of the token to delete | ||
| * @param user the user who owns the token | ||
| * @throws CannotFindTokenException if the token is not found or doesn't belong to the user | ||
| */ | ||
| void deleteToken(String tokenId, IUser user) throws CannotFindTokenException; | ||
|
|
||
| /** | ||
| * Regenerates a personal access token, invalidating the old token value | ||
| * and creating a new one. | ||
| * | ||
| * @param tokenId the ID of the token to regenerate | ||
| * @param user the user who owns the token | ||
| * @return credentials containing the token ID and new token value | ||
| * @throws CannotFindTokenException if the token is not found or doesn't belong to the user | ||
| */ | ||
| PersonalAccessTokenCredentials regenerateToken(String tokenId, IUser user) throws CannotFindTokenException; | ||
|
|
||
| /** | ||
| * Gets a personal access token by ID. | ||
| * | ||
| * @param tokenId the ID of the token | ||
| * @return the token, or null if not found | ||
| */ | ||
| IPersonalAccessToken getTokenById(String tokenId); | ||
| } |
43 changes: 43 additions & 0 deletions
43
...ain/java/edu/asu/diging/citesphere/core/service/oauth/PersonalAccessTokenCredentials.java
This file contains hidden or 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,43 @@ | ||
| package edu.asu.diging.citesphere.core.service.oauth; | ||
|
|
||
| /** | ||
| * This class is a temporary holder for personal access token ID and token value | ||
| * to be used after creation of a new token. The token value should only be shown | ||
| * once to the user and not stored unencrypted. | ||
| */ | ||
| public class PersonalAccessTokenCredentials { | ||
|
|
||
| private String tokenId; | ||
| private String tokenValue; | ||
| private String name; | ||
|
|
||
| public PersonalAccessTokenCredentials(String tokenId, String tokenValue, String name) { | ||
| this.tokenId = tokenId; | ||
| this.tokenValue = tokenValue; | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getTokenId() { | ||
| return tokenId; | ||
| } | ||
|
|
||
| public void setTokenId(String tokenId) { | ||
| this.tokenId = tokenId; | ||
| } | ||
|
|
||
| public String getTokenValue() { | ||
| return tokenValue; | ||
| } | ||
|
|
||
| public void setTokenValue(String tokenValue) { | ||
| this.tokenValue = tokenValue; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation