Skip to content

Instantly share code, notes, and snippets.

View janakamarasena's full-sized avatar

Janak Amarasena janakamarasena

View GitHub Profile
#!/bin/bash +x
wget https://raw.githubusercontent.com/mevan-karu/pom_version_property_finder/master/src/version_property_finder.py
wget https://gist.githubusercontent.com/janakamarasena/d84e5383805a352cd186121f2f491435/raw/fed8a22868e1f346495be849bb75982b5e95ca9f/testng.xml
echo ""
echo "=========================================================="
PR_LINK=${PR_LINK%/}
echo " PR_LINK: $PR_LINK"
echo "::warning::Build ran for PR $PR_LINK"
@janakamarasena
janakamarasena / account-linking-complete.js
Last active May 17, 2020 17:17
Blog - complete account linking script combining scenario 1(advance) and scenario 2 scripts.
var onLoginRequest = function onLoginRequest(context) {
var isLinkRequest = false;
if (context.request.params.isLinkRequest !== null) {
// Get the isLinkRequest param value from the request
isLinkRequest = context.request.params.isLinkRequest[0];
}
var fedIdp;
if (isLinkRequest == "true") {
@janakamarasena
janakamarasena / account-linking-s2.js
Last active May 17, 2020 17:00
Blog - account linking scenario 2, association script.
var onLoginRequest = function onLoginRequest(context) {
var isLinkRequest = false;
if (context.request.params.isLinkRequest !== null) {
// Get the isLinkRequest param value from the request
isLinkRequest = context.request.params.isLinkRequest[0];
}
var fedIdp;
if (isLinkRequest == "true") {
@janakamarasena
janakamarasena / associationConsentForm.jsp
Created May 17, 2020 00:28
Blog - account linking scenario 1, advance association script, JSP consent page.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:directive.include file="../includes/init-url.jsp"/>
<div>
<h2>
We found an already registerd account with the email "<c:out value='${requestScope.data["email"]}'/>" do you want to link it?
</h2>
</div>
<div class="boarder-all ">
@janakamarasena
janakamarasena / account-linking-s1-advance.js
Last active June 23, 2020 15:51
Blog - account linking scenario 1, advance association script.
var onLoginRequest = function onLoginRequest(context) {
var fedUser;
executeStep(1,
{
onSuccess: function (context) {
var idpName = context.steps[1].idp;
// Only execute this flow when the user login from the google idp.
// If you want to target all your idps you can use something like
@janakamarasena
janakamarasena / account-linking-s1-basic.js
Created May 16, 2020 23:51
Blog - account linking scenario 1, basic association script.
var onLoginRequest = function onLoginRequest(context) {
var fedUser;
executeStep(1,
{
onSuccess: function (context) {
var idpName = context.steps[1].idp;
// Only execute this flow when the user login from the google idp.
// If you want to target all your idps you can use something like
@janakamarasena
janakamarasena / account-linking.js
Created May 15, 2020 22:08
account-linking.js
var onLoginRequest = function onLoginRequest(context) {
var isLinkRequest = false;
if (context.request.params.isLinkRequest !== null) {
isLinkRequest = context.request.params.isLinkRequest[0];
}
var localUser;
executeStep(1,
{
onSuccess: function (context) {
// Get the local user
@janakamarasena
janakamarasena / secret_gen.rb
Last active May 2, 2024 01:21
Sign In with Apple Client Secret Generator
require "jwt"
key_file = "Path to the private key"
team_id = "Your Team ID"
client_id = "The Service ID of the service you created"
key_id = "The Key ID of the private key"
validity_period = 180 # In days. Max 180 (6 months) according to Apple docs.
private_key = OpenSSL::PKey::EC.new IO.read key_file
...
final String AUTH_FAILURE_PARAM = "authFailure";
final String AUTH_FAILURE_MSG_PARAM = "authFailureMsg";
...
if (StringUtils.isNotEmpty(request.getParameter(AUTH_FAILURE_PARAM))
&& "true".equals(request.getParameter(AUTH_FAILURE_PARAM))) {
loginFailed = "true";
if (request.getParameter(AUTH_FAILURE_MSG_PARAM) != null) {
errorMessage = request.getParameter(AUTH_FAILURE_MSG_PARAM);
if (errorMessage.equalsIgnoreCase("login.fail.message")) {