-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
88 changed files
with
4,491 additions
and
1,871 deletions.
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
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 |
---|---|---|
@@ -1,23 +1,33 @@ | ||
FROM openjdk:11-slim AS builder | ||
FROM adoptopenjdk/openjdk12-openj9:alpine AS builder | ||
ENV LEIN_ROOT true | ||
RUN apt-get update && apt-get install -y curl | ||
RUN curl -Lo /usr/bin/lein https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein && chmod +x /usr/bin/lein | ||
RUN apk --no-cache add curl bash \ | ||
&& curl -Lo /usr/bin/lein https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein \ | ||
&& chmod +x /usr/bin/lein | ||
WORKDIR /app | ||
COPY project.clj . | ||
RUN lein deps | ||
COPY ./scripts ./scripts | ||
COPY ./src ./src | ||
COPY ./env ./env | ||
COPY ./dev-resources ./dev-resources | ||
COPY ./resources ./resources | ||
COPY ./test ./test | ||
COPY ./test-resources ./test-resources | ||
COPY prod.cljs.edn . | ||
RUN lein test | ||
RUN lein with-profile provided,prod do clean, garden once, minify-assets, fig:min | ||
RUN ./scripts/tag-assets.sh | ||
RUN lein uberjar | ||
COPY decklist.cljs.edn pairings.cljs.edn ./ | ||
RUN lein do \ | ||
test, \ | ||
kibit, \ | ||
eastwood, \ | ||
cljfmt check \ | ||
&& lein with-profile provided,prod do \ | ||
clean, \ | ||
garden once, \ | ||
minify-assets, \ | ||
fig:min pairings, \ | ||
fig:min decklist, \ | ||
buster, \ | ||
uberjar | ||
|
||
FROM openjdk:11-jre-slim | ||
FROM adoptopenjdk/openjdk12-openj9:alpine-jre | ||
WORKDIR /app | ||
COPY --from=builder /app/target/mtg-pairings.jar . | ||
CMD ["java", "-jar", "mtg-pairings.jar"] |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{:main mtg-pairings-server.decklist | ||
:output-to "target/public/js/decklist-main.js" | ||
:output-dir "target/public/js/compiled/decklist" | ||
:optimizations :advanced} |
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 @@ | ||
../../../resources/private/slider.css |
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
8 changes: 0 additions & 8 deletions
8
mtg-pairings-server/env/prod/cljs/mtg_pairings_server/prod.cljs
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
{:main mtg-pairings-server.pairings | ||
:output-to "target/public/js/pairings-main.js" | ||
:output-dir "target/public/js/compiled/pairings" | ||
:optimizations :advanced} |
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
(ns mtg-pairings-server.auth | ||
(:require [clojure.string :as str] | ||
[compojure.api.sweet :refer :all] | ||
[config.core :refer [env]] | ||
[ring.util.response :refer [redirect]] | ||
[schema.core :as s] | ||
[korma.core :as sql] | ||
[mtg-pairings-server.sql-db :as db] | ||
[mtg-pairings-server.util.sql :as sql-util]) | ||
(:import (java.security MessageDigest))) | ||
|
||
(defn ^:private ->hex [bytes] | ||
(str/join (for [b bytes] (format "%02x" b)))) | ||
|
||
(defn ^:private authenticate [username password] | ||
(when-let [user (sql-util/select-unique-or-nil db/smf-user | ||
(sql/fields [:id_member :id] [:passwd :hash]) | ||
(sql/where {:member_name username}))] | ||
(let [input (str (str/lower-case username) password) | ||
md (doto (MessageDigest/getInstance "SHA-1") | ||
(.update (.getBytes input "UTF-8"))) | ||
sha1 (->hex (.digest md))] | ||
(when (= sha1 (:hash user)) | ||
{:id (:id user) | ||
:username username})))) | ||
|
||
(defn organizer-path [] | ||
(if (str/blank? (env :decklist-prefix)) | ||
"/decklist/organizer" | ||
"/organizer")) | ||
|
||
(defroutes auth-routes | ||
(POST "/login" request | ||
:form-params [username :- s/Str | ||
password :- s/Str | ||
__anti-forgery-token :- s/Str] | ||
:query-params [next :- s/Str] | ||
(if-let [user (authenticate username password)] | ||
(let [new-session (assoc (:session request) :identity user)] | ||
(assoc (redirect next :see-other) | ||
:session new-session)) | ||
(redirect (organizer-path) :see-other))) | ||
(GET "/logout" request | ||
(let [new-session (dissoc (:session request) :identity)] | ||
(assoc (redirect (organizer-path) :see-other) | ||
:session new-session)))) |
Oops, something went wrong.