Skip to content

Commit

Permalink
added login with Amazon
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed Mar 31, 2020
1 parent 43e1003 commit 2bd9224
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/erudika/scoold/ScooldServer.java
Expand Up @@ -238,6 +238,8 @@ public ParaClient paraClientBean() {
settings.put("ms_secret", Config.MICROSOFT_SECRET);
settings.put("sl_app_id", Config.SLACK_APP_ID);
settings.put("sl_secret", Config.SLACK_SECRET);
settings.put("az_app_id", Config.AMAZON_APP_ID);
settings.put("az_secret", Config.AMAZON_SECRET);
// OAuth 2 settings
settings.putAll(oauthSettings(""));
settings.putAll(oauthSettings("second"));
Expand Down
Expand Up @@ -81,6 +81,7 @@ public String get(@RequestParam(name = "returnto", required = false, defaultValu
model.addAttribute("twLoginEnabled", !Config.TWITTER_APP_ID.isEmpty());
model.addAttribute("msLoginEnabled", !Config.MICROSOFT_APP_ID.isEmpty());
model.addAttribute("slLoginEnabled", !Config.SLACK_APP_ID.isEmpty());
model.addAttribute("azLoginEnabled", !Config.AMAZON_APP_ID.isEmpty());
model.addAttribute("oa2LoginEnabled", !Config.getConfigParam("oa2_app_id", "").isEmpty());
model.addAttribute("oa2secondLoginEnabled", !Config.getConfigParam("oa2second_app_id", "").isEmpty());
model.addAttribute("oa2thirdLoginEnabled", !Config.getConfigParam("oa2third_app_id", "").isEmpty());
Expand Down Expand Up @@ -237,6 +238,7 @@ public ResponseEntity<String> globals(HttpServletRequest req, HttpServletRespons
sb.append("TWITTER_APP_ID = \"").append(Config.TWITTER_APP_ID).append("\"; ");
sb.append("MICROSOFT_APP_ID = \"").append(Config.MICROSOFT_APP_ID).append("\"; ");
sb.append("SLACK_APP_ID = \"").append(Config.SLACK_APP_ID).append("\"; ");
sb.append("AMAZON_APP_ID = \"").append(Config.AMAZON_APP_ID).append("\"; ");

sb.append("OAUTH2_ENDPOINT = \"").append(Config.getConfigParam("security.oauth.authz_url", "")).append("\"; ");
sb.append("OAUTH2_APP_ID = \"").append(Config.getConfigParam("oa2_app_id", "")).append("\"; ");
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang_en.properties
Expand Up @@ -205,6 +205,7 @@ signin.twitter = Continue with Twitter
signin.microsoft = Continue with Microsoft
signin.slack = Continue with Slack
signin.mattermost = Continue with Mattermost
signin.amazon = Continue with Amazon
signin.password = Continue with Email
profile.changepic = Change picture
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/static/images/amazon.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion src/main/resources/static/scripts/signin.js
@@ -1,4 +1,4 @@
/* global FB_APP_ID, gapi, FB, GOOGLE_CLIENT_ID, GITHUB_APP_ID, LINKEDIN_APP_ID, APPID, ENDPOINT, TWITTER_APP_ID, MICROSOFT_APP_ID, CONTEXT_PATH, OAUTH2_APP_ID, OAUTH2_SCOPE, OAUTH2_ENDPOINT, SLACK_APP_ID, OAUTH2_SECOND_APP_ID, OAUTH2_SECOND_ENDPOINT, OAUTH2_SECOND_SCOPE, OAUTH2_THIRD_APP_ID, OAUTH2_THIRD_ENDPOINT, OAUTH2_THIRD_SCOPE */
/* global FB_APP_ID, gapi, FB, GOOGLE_CLIENT_ID, GITHUB_APP_ID, LINKEDIN_APP_ID, APPID, ENDPOINT, TWITTER_APP_ID, MICROSOFT_APP_ID, CONTEXT_PATH, OAUTH2_APP_ID, OAUTH2_SCOPE, OAUTH2_ENDPOINT, SLACK_APP_ID, OAUTH2_SECOND_APP_ID, OAUTH2_SECOND_ENDPOINT, OAUTH2_SECOND_SCOPE, OAUTH2_THIRD_APP_ID, OAUTH2_THIRD_ENDPOINT, OAUTH2_THIRD_SCOPE, AMAZON_APP_ID */
/************************
* Facebook integration *
************************/
Expand Down Expand Up @@ -91,6 +91,18 @@ if (SLACK_APP_ID && SLACK_APP_ID.trim() !== "") {
return false;
});
}
/*************************
* Amazon integration *
*************************/
if (AMAZON_APP_ID && AMAZON_APP_ID.trim() !== "") {
$('#az-login-btn').on('click', function () {
window.location = "https://www.amazon.com/ap/oa?" +
"response_type=code&client_id=" + AMAZON_APP_ID +
"&scope=profile&state=" + APPID +
"&redirect_uri=" + ENDPOINT + "/amazon_auth";
return false;
});
}
/*************************
* OAuth 2.0 integration *
*************************/
Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/static/styles/style.css
Expand Up @@ -80,8 +80,11 @@ hr { height: 1px; border: 0; background-color: #CCC; width: 100%;}
.editor-toolbar button { color: #555555; }
h1, h2, h3, h4, h5, h6{font-weight: 300;}

#fb-login-btn, #gp-login-btn, #gh-login-btn, #in-login-btn, #tw-login-btn, #ms-login-btn, #sl-login-btn, #oa2-login-btn { width: 100%; }
#gp-login-btn, #sl-login-btn {padding-left: 13px;}
#fb-login-btn, #gp-login-btn, #gh-login-btn, #in-login-btn, #tw-login-btn, #ms-login-btn, #sl-login-btn,
#az-login-btn, #oa2-login-btn { width: 100%; }
#gp-login-btn, #sl-login-btn, #az-login-btn {padding-left: 13px;}
#sl-login-btn { background-color: white; color: #222; }
#az-login-btn { background-color: #fad673; color: #222; }

.leaveblank {opacity: 0.0001;}

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/templates/profile.vm
Expand Up @@ -3,6 +3,7 @@
<div class="card">
<div class="card-image">
<img src="#profilepic($showUser)" id="profile_${showUser.creatorid}" class="profile-pic on-profile-page">
#if($canEdit)
<span class="card-title">
#if($showUser.user.identifier.startsWith("fb"))
<i class="fa fa-facebook fa-2x" title="Facebook"></i>
Expand All @@ -18,12 +19,15 @@
<i class="fa fa-windows fa-2x" title="Microsoft"></i>
#elseif($showUser.user.identifier.startsWith("sl"))
<i class="fa fa-slack fa-2x" title="Slack"></i>
#elseif($showUser.user.identifier.startsWith("az"))
<i class="fa fa-amazon fa-2x" title="Amazon"></i>
#elseif($showUser.user.identifier.startsWith("oa2"))
<i class="fa fa-openid fa-2x" title="OAuth 2.0"></i>
#elseif($showUser.user.identifier.startsWith("ldap"))
<i class="fa fa-id-card-o fa-2x" title="LDAP"></i>
#end
</span>
#end
</div>
<div class="card-content center-align">
#if ($canEdit && $canEditAvatar)
Expand Down
15 changes: 12 additions & 3 deletions src/main/resources/templates/signin.vm
Expand Up @@ -104,7 +104,7 @@
#end

#if(!$fbLoginEnabled && !$gpLoginEnabled && !$ghLoginEnabled && !$inLoginEnabled && !$twLoginEnabled &&
!$msLoginEnabled && !$slLoginEnabled && !$oa2LoginEnabled && !$oa2secondLoginEnabled && !$oa2thirdLoginEnabled)
!$msLoginEnabled && !$slLoginEnabled && !$azLoginEnabled && !$oa2LoginEnabled && !$oa2secondLoginEnabled && !$oa2thirdLoginEnabled)
#set($leftColSize = "col l6 offset-l3 s12" )
#set($rightColSize = "hide" )
#end
Expand Down Expand Up @@ -214,15 +214,24 @@
#end

#if($slLoginEnabled)
<div class="mvl pvs">
<a id="sl-login-btn" href="#" class="btn-large white grey-text text-darken-1 truncate pls prl">
<div class="mvl pvs">
<a id="sl-login-btn" href="#" class="btn-large grey-text truncate pls prl">
<img src="https://cdn.brandfolder.io/5H442O3W/as/pl546j-7le8zk-199wkt/Slack_Mark.svg"
width="54" height="54" alt="Slack logo" class="left"/>
$!lang.get("signin.slack")
</a>
</div>
#end

#if($azLoginEnabled)
<div class="mvl pvs">
<a id="az-login-btn" href="#" class="btn-large grey-text truncate pls prl">
<img src="$imageslink/amazon.svg" width="50" height="50" alt="Amazon logo" class="left pts phm"/>
$!lang.get("signin.amazon")
</a>
</div>
#end

#if($oa2LoginEnabled)
<div class="mvl pvs">
<a id="oa2-login-btn" href="#" class="btn-large grey darken-2 truncate">
Expand Down

0 comments on commit 2bd9224

Please sign in to comment.