-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: challenge endpoint #56
Merged
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
967e84b
feat: Auth refresh service implementation
f604b49
feat: Auth refresh query implementation
fbb3063
fix: Additional property attach not allowed on postgres-admin service
498abaf
docs: Auth refresh update on api specification
d81ddec
feat: Auth refresh test implementaion
8470319
Merge branch 'dev' into feat/challenge
crijumubu 2733db8
fix: Fix typos on controller
b1d7d45
docs: Update response schema on auth refresh
92c7f0e
Merge dev into feat/challenge
de9d587
feat: Update soap python client for auth refresh
d0d7865
Fix: Code formatting
f0d79b8
style: adjust spaces
Woynert b1a9634
chore: keep simple.py simple
Woynert 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 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,52 @@ | ||
package gateway.controller; | ||
|
||
import gateway.config.Config; | ||
import gateway.soap.request.Authorization; | ||
import gateway.soap.response.ResSession; | ||
import org.json.JSONObject; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.net.http.HttpClient; | ||
import java.net.http.HttpRequest; | ||
import java.net.http.HttpResponse; | ||
|
||
public class CtrlAuthRefresh { | ||
|
||
public static ResSession auth_refresh (Authorization authorization) | ||
{ | ||
ResSession res = new ResSession (); | ||
|
||
String url = Config.getAuthBaseUrl () + "/challenge"; | ||
|
||
try { | ||
|
||
HttpResponse<String> response = HttpClient.newHttpClient ().send ( | ||
HttpRequest.newBuilder () | ||
.uri (URI.create (url)) | ||
.POST (HttpRequest.BodyPublishers.noBody ()) | ||
.uri (URI.create (url)) | ||
.header("Authorization", "Bearer " + authorization.token) | ||
.build (), | ||
HttpResponse.BodyHandlers.ofString ()); | ||
|
||
// Response | ||
JSONObject jsonObject = new JSONObject (response.body ()); | ||
res.code = response.statusCode (); | ||
|
||
if (res.code == 200) { | ||
res.auth = new Authorization(); | ||
res.error = false; | ||
res.auth.token = jsonObject.getString ("jwt"); | ||
} else { | ||
res.error = true; | ||
res.msg = jsonObject.getString ("msg"); | ||
} | ||
|
||
} catch (IOException | InterruptedException e) { | ||
e.printStackTrace (); | ||
} | ||
|
||
return res; | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,5 +79,4 @@ services: | |
ADMINER_DEFAULT_PORT: 5432 | ||
ADMINER_DEFAULT_DB: metadatadb | ||
networks: | ||
- net | ||
attach: false | ||
- net |
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
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.
Technically we always return a ResSession but it's not guaranteed that the relevant fields will be filled if there is an exception (i.e. a code different from 20x).
So instead let it as ResStatus which is guaranteed to be complete (exception), also it allows us to be consistent with the other endpoints. Which always return a ResStatus in case something wrong happens.