diff --git a/.env.example b/.env.example index dc99ade..b219601 100644 --- a/.env.example +++ b/.env.example @@ -6,10 +6,3 @@ CASTLE_API_SECRET= # Publishable key, used by the browser SDK to mint request tokens. CASTLE_PK= - -# Optional: Twitter/X OAuth credentials for the social login demo. -TWITTER_APP_ID= -TWITTER_SECRET= - -# Required in production only (generate with `bin/rails secret`). -# SECRET_KEY_BASE= diff --git a/Gemfile b/Gemfile index d3cc81c..739bd4c 100644 --- a/Gemfile +++ b/Gemfile @@ -9,8 +9,6 @@ gem 'castle-rb', '~> 8.1' gem 'devise', '~> 5.0' gem 'dotenv-rails' gem 'hamlit-rails' -gem 'omniauth-rails_csrf_protection' -gem 'omniauth-twitter' gem 'puma', '~> 6.4' gem 'rails', '~> 8.1.3' gem 'responders' diff --git a/Gemfile.lock b/Gemfile.lock index 67e6933..2f474ee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,8 +75,6 @@ GEM securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) - auth-sanitizer (0.1.4) - version_gem (~> 1.1, >= 1.1.9) base64 (0.3.0) bcrypt (3.1.22) bigdecimal (4.1.2) @@ -87,7 +85,6 @@ GEM byebug (13.0.0) reline (>= 0.6.0) castle-rb (8.1.0) - cgi (0.5.1) concurrent-ruby (1.3.6) connection_pool (3.0.2) crass (1.0.6) @@ -125,8 +122,6 @@ GEM activesupport (>= 4.0.1) hamlit (>= 1.2.0) railties (>= 4.0.1) - hashie (5.1.0) - logger i18n (1.14.8) concurrent-ruby (~> 1.0) io-console (0.8.2) @@ -172,32 +167,6 @@ GEM racc (~> 1.4) nokogiri (1.19.3-x86_64-linux-gnu) racc (~> 1.4) - oauth (1.1.5) - auth-sanitizer (~> 0.1, >= 0.1.3) - base64 (~> 0.1) - cgi - oauth-tty (~> 1.0, >= 1.0.8) - snaky_hash (~> 2.0, >= 2.0.4) - version_gem (~> 1.1, >= 1.1.9) - oauth-tty (1.0.8) - auth-sanitizer (~> 0.1, >= 0.1.3) - cgi - version_gem (~> 1.1, >= 1.1.9) - omniauth (2.1.4) - hashie (>= 3.4.6) - logger - rack (>= 2.2.3) - rack-protection - omniauth-oauth (1.2.1) - oauth - omniauth (>= 1.0, < 3) - rack (>= 1.6.2, < 4) - omniauth-rails_csrf_protection (2.0.1) - actionpack (>= 4.2) - omniauth (~> 2.0) - omniauth-twitter (1.4.0) - omniauth-oauth (~> 1.1) - rack orm_adapter (0.5.0) pp (0.6.3) prettyprint @@ -210,10 +179,6 @@ GEM nio4r (~> 2.0) racc (1.8.1) rack (3.2.6) - rack-protection (4.2.1) - base64 (>= 0.1.0) - logger (>= 1.6.0) - rack (>= 3.0.0, < 4) rack-session (2.1.2) base64 (>= 0.1.0) rack (>= 3.0.0) @@ -292,9 +257,6 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.13.2) simplecov_json_formatter (0.1.4) - snaky_hash (2.0.4) - hashie (>= 0.1.0, < 6) - version_gem (>= 1.1.8, < 3) sprockets (4.2.2) concurrent-ruby (~> 1.0) logger @@ -325,7 +287,6 @@ GEM concurrent-ruby (~> 1.0) uri (1.1.1) useragent (0.16.11) - version_gem (1.1.10) warden (1.2.9) rack (>= 2.0.9) web-console (4.2.1) @@ -354,8 +315,6 @@ DEPENDENCIES factory_bot_rails faker hamlit-rails - omniauth-rails_csrf_protection - omniauth-twitter puma (~> 6.4) rails (~> 8.1.3) rails-controller-testing diff --git a/README.md b/README.md index 52f6f99..3550a0a 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,6 @@ SDK (8.x). - **logout, profile updates & custom events** – recorded with the non-blocking `log` endpoint. The custom event is available from the profile page, once signed in. -- **Twitter/X OAuth login** – the same risk assessment applied to social sign-in. - **webhooks** – incoming Castle webhooks are signature-verified with `Castle::Webhooks::Verify` and listed in the app. - **browser SDK** – the `@castleio/castle-js` SDK mints a request token in the @@ -31,17 +30,19 @@ SDK (8.x). ## Prerequisites You'll need a Castle account. If you don't have one, start a free trial at -https://castle.io. From the dashboard (Settings → API) you'll need: +https://castle.io. For local development, use a **sandbox** environment so demo +traffic from `localhost` stays separate from production data — from the Castle +dashboard (Settings → API) grab the sandbox keys: -- your **publishable key** (`pk`) – used by the browser SDK -- your **API secret** – used by the backend SDK +- your **publishable key** (`CASTLE_PK`) – used by the browser SDK +- your **API secret** (`CASTLE_API_SECRET`) – used by the backend SDK + +These are the only two values you need to configure. ## Running locally This app targets **Ruby 3.4** (see `.ruby-version`). -Clone the repo and install dependencies: - ```bash git clone https://github.com/castle/castle-ruby-example.git cd castle-ruby-example @@ -66,38 +67,6 @@ bin/rails server `bin/setup` runs the dependency install, file copying and database setup in one step. -## Styling (Tailwind CSS) - -The UI is styled with [Tailwind CSS](https://tailwindcss.com) via the -[`tailwindcss-rails`](https://github.com/rails/tailwindcss-rails) gem (no Node -toolchain required). The source is `app/assets/stylesheets/application.tailwind.css` -with design tokens in `config/tailwind.config.js`; it compiles to -`app/assets/builds/tailwind.css`, which is committed so `bin/rails server` works -without a build step. - -If you change the views or the Tailwind source, regenerate the stylesheet: - -```bash -bin/rails tailwindcss:build # one-off build -bin/rails tailwindcss:watch # rebuild on change during development -``` - -`assets:precompile` (used by the Docker build) runs `tailwindcss:build` -automatically. - -## Configuration - -All configuration is read from environment variables (loaded from `.env` in -development and test via `dotenv-rails`): - -| Variable | Purpose | -| -------------------- | ---------------------------------------------------- | -| `CASTLE_API_SECRET` | Server-side API secret used by the `castle-rb` SDK. | -| `CASTLE_PK` | Publishable key used by the browser SDK. | -| `TWITTER_APP_ID` | Optional – enables the Twitter/X OAuth login button. | -| `TWITTER_SECRET` | Optional – Twitter/X OAuth secret. | -| `SECRET_KEY_BASE` | Required in production only. | - ## Running the tests ```bash @@ -110,24 +79,18 @@ The bundled `Dockerfile` is a multi-stage build that compiles assets and runs the app with Puma as an unprivileged user on port 3000. The SQLite database is created on first boot. -Build the image: - ```bash docker build -t castle-demo-ruby . -``` -Run a container, passing your Castle credentials: - -```bash docker run -d -p 4006:3000 \ -e CASTLE_API_SECRET=YOUR_API_SECRET \ -e CASTLE_PK=YOUR_PUBLISHABLE_KEY \ castle-demo-ruby ``` -The app will be available at http://127.0.0.1:4006. A `SECRET_KEY_BASE` is -generated automatically if you don't supply one (set it explicitly to keep -sessions across restarts). +The app will be available at http://127.0.0.1:4006. Point it at a Castle sandbox +environment when running locally. A `SECRET_KEY_BASE` is generated automatically +if you don't supply one (set it explicitly to keep sessions across restarts). ## Disclaimer diff --git a/app/assets/builds/tailwind.css b/app/assets/builds/tailwind.css index 260fc20..4b67b79 100644 --- a/app/assets/builds/tailwind.css +++ b/app/assets/builds/tailwind.css @@ -1 +1 @@ -*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:Inter,ui-sans-serif,system-ui,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}body{min-height:100vh;--tw-bg-opacity:1;background-color:rgb(11 14 20/var(--tw-bg-opacity,1));color:rgb(230 233 239/var(--tw-text-opacity,1));font-family:Inter,ui-sans-serif,system-ui,sans-serif;font-size:15px;line-height:1.625;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background-image:radial-gradient(1200px 600px at 80% -10%,rgba(124,92,255,.12),transparent 60%)}a,body{--tw-text-opacity:1}a{color:rgb(124 92 255/var(--tw-text-opacity,1));text-decoration-line:none}a:hover{text-decoration-line:underline}h1,h2,h3,h4{font-weight:600;line-height:1.25}p{margin-bottom:.75rem}code{border-radius:.25rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(35 43 57/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(27 34 48/var(--tw-bg-opacity,1));font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.86em;padding:.125rem .375rem}.relative{position:relative}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.block{display:block}.inline{display:inline}.table{display:table}.hidden{display:none}.w-full{width:100%}.list-disc{list-style-type:disc}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.border{border-width:1px}.pl-5{padding-left:1.25rem}.text-center{text-align:center}.text-\[1\.2rem\]{font-size:1.2rem}.text-\[1\.3rem\]{font-size:1.3rem}.text-\[1\.4rem\]{font-size:1.4rem}.text-\[2rem\]{font-size:2rem}.text-muted{--tw-text-opacity:1;color:rgb(154 164 178/var(--tw-text-opacity,1))}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.navbar{border-bottom-width:1px;flex-wrap:wrap;gap:1.5rem;position:sticky;top:0;z-index:50;--tw-border-opacity:1;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);background:rgba(13,16,22,.8);border-color:rgb(35 43 57/var(--tw-border-opacity,1));padding:.875rem 1.5rem}.brand,.navbar{align-items:center;display:flex}.brand{font-size:1.05rem;font-weight:700;gap:.5rem;--tw-text-opacity:1;color:rgb(230 233 239/var(--tw-text-opacity,1))}.brand:hover{text-decoration-line:none}.brand-dot{border-radius:9999px;height:.625rem;width:.625rem;--tw-bg-opacity:1;background-color:rgb(124 92 255/var(--tw-bg-opacity,1));box-shadow:0 0 12px #7c5cff}.nav-links{align-items:center;display:flex;flex-wrap:wrap;gap:1.25rem;margin-left:auto}.nav-links a{font-size:.92rem;--tw-text-opacity:1;color:rgb(154 164 178/var(--tw-text-opacity,1))}.nav-links a:hover{--tw-text-opacity:1;color:rgb(230 233 239/var(--tw-text-opacity,1));text-decoration-line:none}.nav-links form{display:inline;margin:0}.nav-links form button{background-color:transparent;border-width:0;cursor:pointer;font-size:.92rem;padding:0;--tw-text-opacity:1;color:rgb(154 164 178/var(--tw-text-opacity,1))}.nav-links form button:hover{--tw-text-opacity:1;color:rgb(230 233 239/var(--tw-text-opacity,1))}.tag{background-color:rgba(124,92,255,.1);border-color:rgba(124,92,255,.4);border-radius:9999px;border-width:1px;font-size:.75rem;font-weight:600;line-height:1rem;padding:.125rem .5rem;--tw-text-opacity:1;color:rgb(124 92 255/var(--tw-text-opacity,1))}.container-page{margin-left:auto;margin-right:auto;max-width:1120px;padding:2rem 1.5rem 4rem}.container-narrow{margin-left:auto;margin-right:auto;max-width:420px;padding:4rem 1.5rem;width:100%}.card{border-radius:14px;border-width:1px;--tw-border-opacity:1;border-color:rgb(35 43 57/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(21 26 35/var(--tw-bg-opacity,1));padding:1.5rem;--tw-shadow:0 10px 30px rgba(0,0,0,.35);--tw-shadow-colored:0 10px 30px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.eyebrow{font-size:.75rem;font-weight:700;letter-spacing:.05em;line-height:1rem;margin-bottom:.375rem;text-transform:uppercase;--tw-text-opacity:1;color:rgb(154 164 178/var(--tw-text-opacity,1))}.hero{margin-bottom:2rem;padding:2rem}.feature,.hero{border-radius:14px;border-width:1px;--tw-border-opacity:1;border-color:rgb(35 43 57/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(21 26 35/var(--tw-bg-opacity,1))}.feature{display:block;padding:1.25rem;text-align:left;transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.feature:hover{--tw-translate-y:-0.125rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));--tw-border-opacity:1;border-color:rgb(124 92 255/var(--tw-border-opacity,1));text-decoration-line:none}.section-head{border-bottom-width:1px;margin-bottom:.75rem;margin-top:2rem;--tw-border-opacity:1;border-color:rgb(35 43 57/var(--tw-border-opacity,1));padding-bottom:.5rem}.prose-list>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.field{margin-bottom:.875rem}.field label{display:block;font-size:.82rem;font-weight:600;margin-bottom:.375rem;--tw-text-opacity:1;color:rgb(154 164 178/var(--tw-text-opacity,1))}.input,input[type=email],input[type=password],input[type=text]{border-radius:9px;border-width:1px;width:100%;--tw-border-opacity:1;border-color:rgb(35 43 57/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(17 21 31/var(--tw-bg-opacity,1));font-family:Inter,ui-sans-serif,system-ui,sans-serif;font-size:.95rem;padding:.625rem .75rem;--tw-text-opacity:1;color:rgb(230 233 239/var(--tw-text-opacity,1));transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.input:focus,input[type=email]:focus,input[type=password]:focus,input[type=text]:focus{--tw-border-opacity:1;border-color:rgb(124 92 255/var(--tw-border-opacity,1));box-shadow:0 0 0 3px rgba(124,92,255,.14);outline:2px solid transparent;outline-offset:2px}.btn{border-radius:9px;border-width:1px;cursor:pointer;display:inline-block;--tw-border-opacity:1;border-color:rgb(35 43 57/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(27 34 48/var(--tw-bg-opacity,1));font-family:Inter,ui-sans-serif,system-ui,sans-serif;font-size:.92rem;font-weight:600;padding:.625rem 1rem;text-align:center;--tw-text-opacity:1;color:rgb(230 233 239/var(--tw-text-opacity,1));text-decoration-line:none;transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.btn:hover{--tw-border-opacity:1;border-color:rgb(124 92 255/var(--tw-border-opacity,1));text-decoration-line:none}.btn:active{--tw-translate-y:1px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.btn-primary{--tw-border-opacity:1;border-color:rgb(124 92 255/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(124 92 255/var(--tw-bg-opacity,1));--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.btn-primary:hover{--tw-bg-opacity:1;background-color:rgb(107 76 240/var(--tw-bg-opacity,1))}.btn-alt,.btn-ghost{background-color:transparent}.btn-danger{background-color:rgba(255,92,124,.1);border-color:rgba(255,92,124,.5);--tw-text-opacity:1;color:rgb(255 92 124/var(--tw-text-opacity,1))}.btn-row{display:flex;flex-wrap:wrap;gap:.625rem;margin-top:1rem}.alert{align-items:center;border-radius:9px;border-width:1px;display:flex;font-size:.92rem;gap:1rem;justify-content:space-between;margin-bottom:1rem;padding:.75rem 1rem}.alert-success{background-color:rgba(46,204,113,.1);border-color:rgba(46,204,113,.4)}.alert-danger,.alert-success{--tw-text-opacity:1;color:rgb(230 233 239/var(--tw-text-opacity,1))}.alert-danger{background-color:rgba(255,92,124,.1);border-color:rgba(255,92,124,.4)}.alert .btn-close{background-color:transparent;border-width:0;cursor:pointer;font-size:1.125rem;line-height:1.75rem;line-height:1;--tw-text-opacity:1;color:rgb(154 164 178/var(--tw-text-opacity,1))}.alert .btn-close:hover{--tw-text-opacity:1;color:rgb(230 233 239/var(--tw-text-opacity,1))}table.table{border-collapse:collapse;border-radius:9px;font-size:.9rem;overflow:hidden;width:100%}table.table th{border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(35 43 57/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(27 34 48/var(--tw-bg-opacity,1));font-size:.78rem;font-weight:700;letter-spacing:.025em;padding:.5rem .75rem;text-align:left;text-transform:uppercase;--tw-text-opacity:1;color:rgb(154 164 178/var(--tw-text-opacity,1))}table.table td{border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(28 35 48/var(--tw-border-opacity,1));padding:.5rem .75rem;vertical-align:top}.lead{font-size:1.1rem;--tw-text-opacity:1;color:rgb(154 164 178/var(--tw-text-opacity,1))}.form-actions{margin-top:1.25rem}.error,.invalid-feedback{color:rgb(255 92 124/var(--tw-text-opacity,1))}.error,.hint,.invalid-feedback{display:block;font-size:.8rem;margin-top:.25rem;--tw-text-opacity:1}.hint{color:rgb(154 164 178/var(--tw-text-opacity,1))}.field_with_errors{display:contents} \ No newline at end of file +*,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59,130,246,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.19 | MIT License | https://tailwindcss.com*/*,:after,:before{border:0 solid #e5e7eb;box-sizing:border-box}:after,:before{--tw-content:""}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;font-family:Inter,ui-sans-serif,system-ui,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-tap-highlight-color:transparent}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-feature-settings:normal;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{color:inherit;font-family:inherit;font-feature-settings:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{color:#9ca3af;opacity:1}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}body{min-height:100vh;--tw-bg-opacity:1;background-color:rgb(246 248 252/var(--tw-bg-opacity,1));color:rgb(15 23 41/var(--tw-text-opacity,1));font-family:Inter,ui-sans-serif,system-ui,sans-serif;font-size:15px;line-height:1.625;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background-image:radial-gradient(1200px 600px at 80% -10%,rgba(54,94,237,.12),transparent 60%)}a,body{--tw-text-opacity:1}a{color:rgb(54 94 237/var(--tw-text-opacity,1));text-decoration-line:none}a:hover{text-decoration-line:underline}h1,h2,h3,h4{font-weight:600;line-height:1.25}p{margin-bottom:.75rem}code{border-radius:.25rem;border-width:1px;--tw-border-opacity:1;border-color:rgb(221 227 238/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(238 242 251/var(--tw-bg-opacity,1));font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.86em;padding:.125rem .375rem}.relative{position:relative}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.block{display:block}.inline{display:inline}.table{display:table}.hidden{display:none}.w-full{width:100%}.list-disc{list-style-type:disc}.flex-col{flex-direction:column}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-3{gap:.75rem}.border{border-width:1px}.pl-5{padding-left:1.25rem}.text-center{text-align:center}.text-\[1\.2rem\]{font-size:1.2rem}.text-\[1\.3rem\]{font-size:1.3rem}.text-\[1\.4rem\]{font-size:1.4rem}.text-\[2rem\]{font-size:2rem}.text-muted{--tw-text-opacity:1;color:rgb(91 102 120/var(--tw-text-opacity,1))}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.navbar{border-bottom-width:1px;flex-wrap:wrap;gap:1.5rem;position:sticky;top:0;z-index:50;--tw-border-opacity:1;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);background:hsla(0,0%,100%,.8);border-color:rgb(221 227 238/var(--tw-border-opacity,1));padding:.875rem 1.5rem}.brand,.navbar{align-items:center;display:flex}.brand{font-size:1.05rem;font-weight:700;gap:.5rem;--tw-text-opacity:1;color:rgb(15 23 41/var(--tw-text-opacity,1))}.brand:hover{text-decoration-line:none}.brand-logo{flex-shrink:0;height:1.4rem;width:1.4rem;--tw-text-opacity:1;color:rgb(54 94 237/var(--tw-text-opacity,1));filter:drop-shadow(0 0 8px rgba(54,94,237,.35))}.brand-logo-lg{height:3rem;width:3rem}.nav-links{align-items:center;display:flex;flex-wrap:wrap;gap:1.25rem;margin-left:auto}.nav-links a{font-size:.92rem;--tw-text-opacity:1;color:rgb(91 102 120/var(--tw-text-opacity,1))}.nav-links a:hover{--tw-text-opacity:1;color:rgb(15 23 41/var(--tw-text-opacity,1));text-decoration-line:none}.nav-links form{display:inline;margin:0}.nav-links form button{background-color:transparent;border-width:0;cursor:pointer;font-size:.92rem;padding:0;--tw-text-opacity:1;color:rgb(91 102 120/var(--tw-text-opacity,1))}.nav-links form button:hover{--tw-text-opacity:1;color:rgb(15 23 41/var(--tw-text-opacity,1))}.tag{background-color:rgba(54,94,237,.1);border-color:rgba(54,94,237,.4);border-radius:9999px;border-width:1px;font-size:.75rem;font-weight:600;line-height:1rem;padding:.125rem .5rem;--tw-text-opacity:1;color:rgb(54 94 237/var(--tw-text-opacity,1))}.container-page{margin-left:auto;margin-right:auto;max-width:1120px;padding:2rem 1.5rem 4rem}.container-narrow{margin-left:auto;margin-right:auto;max-width:420px;padding:4rem 1.5rem;width:100%}.card{border-radius:14px;border-width:1px;--tw-border-opacity:1;border-color:rgb(221 227 238/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1));padding:1.5rem;--tw-shadow:0 1px 3px rgba(16,24,40,.06),0 8px 24px rgba(16,24,40,.06);--tw-shadow-colored:0 1px 3px var(--tw-shadow-color),0 8px 24px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.eyebrow{font-size:.75rem;font-weight:700;letter-spacing:.05em;line-height:1rem;margin-bottom:.375rem;text-transform:uppercase;--tw-text-opacity:1;color:rgb(91 102 120/var(--tw-text-opacity,1))}.hero{margin-bottom:2rem;padding:2rem}.feature,.hero{border-radius:14px;border-width:1px;--tw-border-opacity:1;border-color:rgb(221 227 238/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.feature{display:block;padding:1.25rem;text-align:left;transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.feature:hover{--tw-translate-y:-0.125rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));--tw-border-opacity:1;border-color:rgb(54 94 237/var(--tw-border-opacity,1));text-decoration-line:none}.section-head{border-bottom-width:1px;margin-bottom:.75rem;margin-top:2rem;--tw-border-opacity:1;border-color:rgb(221 227 238/var(--tw-border-opacity,1));padding-bottom:.5rem}.prose-list>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-bottom:calc(.5rem*var(--tw-space-y-reverse));margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)))}.field{margin-bottom:.875rem}.field label{display:block;font-size:.82rem;font-weight:600;margin-bottom:.375rem;--tw-text-opacity:1;color:rgb(91 102 120/var(--tw-text-opacity,1))}.input,input[type=email],input[type=password],input[type=text]{border-radius:9px;border-width:1px;width:100%;--tw-border-opacity:1;border-color:rgb(221 227 238/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(238 242 249/var(--tw-bg-opacity,1));font-family:Inter,ui-sans-serif,system-ui,sans-serif;font-size:.95rem;padding:.625rem .75rem;--tw-text-opacity:1;color:rgb(15 23 41/var(--tw-text-opacity,1));transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.input:focus,input[type=email]:focus,input[type=password]:focus,input[type=text]:focus{--tw-border-opacity:1;border-color:rgb(54 94 237/var(--tw-border-opacity,1));box-shadow:0 0 0 3px rgba(54,94,237,.14);outline:2px solid transparent;outline-offset:2px}.btn{border-radius:9px;border-width:1px;cursor:pointer;display:inline-block;--tw-border-opacity:1;border-color:rgb(221 227 238/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(238 242 251/var(--tw-bg-opacity,1));font-family:Inter,ui-sans-serif,system-ui,sans-serif;font-size:.92rem;font-weight:600;padding:.625rem 1rem;text-align:center;--tw-text-opacity:1;color:rgb(15 23 41/var(--tw-text-opacity,1));text-decoration-line:none;transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.btn:hover{--tw-border-opacity:1;border-color:rgb(54 94 237/var(--tw-border-opacity,1));text-decoration-line:none}.btn:active{--tw-translate-y:1px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.btn-primary{--tw-border-opacity:1;border-color:rgb(54 94 237/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(54 94 237/var(--tw-bg-opacity,1));--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.btn-primary:hover{--tw-bg-opacity:1;background-color:rgb(42 78 209/var(--tw-bg-opacity,1))}.btn-alt,.btn-ghost{background-color:transparent}.btn-danger{background-color:rgba(220,38,38,.1);border-color:rgba(220,38,38,.5);--tw-text-opacity:1;color:rgb(220 38 38/var(--tw-text-opacity,1))}.btn-row{display:flex;flex-wrap:wrap;gap:.625rem;margin-top:1rem}.alert{align-items:center;border-radius:9px;border-width:1px;display:flex;font-size:.92rem;gap:1rem;justify-content:space-between;margin-bottom:1rem;padding:.75rem 1rem}.alert-success{background-color:rgba(22,163,74,.1);border-color:rgba(22,163,74,.4)}.alert-danger,.alert-success{--tw-text-opacity:1;color:rgb(15 23 41/var(--tw-text-opacity,1))}.alert-danger{background-color:rgba(220,38,38,.1);border-color:rgba(220,38,38,.4)}.alert .btn-close{background-color:transparent;border-width:0;cursor:pointer;font-size:1.125rem;line-height:1.75rem;line-height:1;--tw-text-opacity:1;color:rgb(91 102 120/var(--tw-text-opacity,1))}.alert .btn-close:hover{--tw-text-opacity:1;color:rgb(15 23 41/var(--tw-text-opacity,1))}table.table{border-collapse:collapse;border-radius:9px;font-size:.9rem;overflow:hidden;width:100%}table.table th{border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(221 227 238/var(--tw-border-opacity,1));--tw-bg-opacity:1;background-color:rgb(238 242 251/var(--tw-bg-opacity,1));font-size:.78rem;font-weight:700;letter-spacing:.025em;padding:.5rem .75rem;text-align:left;text-transform:uppercase;--tw-text-opacity:1;color:rgb(91 102 120/var(--tw-text-opacity,1))}table.table td{border-bottom-width:1px;--tw-border-opacity:1;border-color:rgb(233 237 245/var(--tw-border-opacity,1));padding:.5rem .75rem;vertical-align:top}.lead{font-size:1.1rem;--tw-text-opacity:1;color:rgb(91 102 120/var(--tw-text-opacity,1))}.form-actions{margin-top:1.25rem}.error,.invalid-feedback{color:rgb(220 38 38/var(--tw-text-opacity,1))}.error,.hint,.invalid-feedback{display:block;font-size:.8rem;margin-top:.25rem;--tw-text-opacity:1}.hint{color:rgb(91 102 120/var(--tw-text-opacity,1))}.field_with_errors{display:contents} \ No newline at end of file diff --git a/app/assets/stylesheets/application.tailwind.css b/app/assets/stylesheets/application.tailwind.css index 43e7241..f5c4247 100644 --- a/app/assets/stylesheets/application.tailwind.css +++ b/app/assets/stylesheets/application.tailwind.css @@ -7,7 +7,7 @@ @apply min-h-screen bg-bg font-sans text-[15px] leading-relaxed text-ink antialiased; background-image: radial-gradient( 1200px 600px at 80% -10%, - rgba(124, 92, 255, 0.12), + rgba(54, 94, 237, 0.12), transparent 60% ); } @@ -39,7 +39,7 @@ .navbar { @apply sticky top-0 z-50 flex flex-wrap items-center gap-6 border-b border-border px-6 py-3.5; - background: rgba(13, 16, 22, 0.8); + background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(10px); } @@ -47,9 +47,13 @@ @apply flex items-center gap-2 text-[1.05rem] font-bold text-ink hover:no-underline; } -.brand-dot { - @apply h-2.5 w-2.5 rounded-full bg-accent; - box-shadow: 0 0 12px #7c5cff; +.brand-logo { + @apply h-[1.4rem] w-[1.4rem] shrink-0 text-accent; + filter: drop-shadow(0 0 8px rgba(54, 94, 237, 0.35)); +} + +.brand-logo-lg { + @apply h-12 w-12; } .nav-links { @@ -124,7 +128,7 @@ input[type='text']:focus, input[type='email']:focus, input[type='password']:focus { @apply border-accent outline-none; - box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.14); + box-shadow: 0 0 0 3px rgba(54, 94, 237, 0.14); } .btn { diff --git a/app/controllers/integrations/castle_webhooks_controller.rb b/app/controllers/integrations/castle_webhooks_controller.rb index d7e9a5c..241b9d2 100644 --- a/app/controllers/integrations/castle_webhooks_controller.rb +++ b/app/controllers/integrations/castle_webhooks_controller.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true # Module including things related to integrations with other services -# @note This does not apply to oauth as oauth is in the user scope to indicate its -# relationship with the user module Integrations # Controller for receiving Castle incoming webhooks class CastleWebhooksController < ApplicationController diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb deleted file mode 100644 index b9f53a5..0000000 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ /dev/null @@ -1,70 +0,0 @@ -# frozen_string_literal: true - -# Namespace for all the things related to working with users -module Users - # OmniAuth authentication for Devise with Castle.io tracking - class OmniauthCallbacksController < Devise::OmniauthCallbacksController - layout 'devise' - - # Twitter OAuth endpoint - def twitter - current_user = User.find_or_create_for_oauth request.env['omniauth.auth'] - - if current_user.persisted? - authenticate(current_user) - else - flash[:error] = t('.error') - redirect_to new_user_registration_url - report_failed_login(current_user) - end - end - - private - - # Checks if user can be authenticated and if so user will be signed in. - # @param current_user [User] user that we want to authenticate - def authenticate(current_user) - if evaluate_login(current_user) == 'deny' - warden.logout - flash[:error] = t('.access_denied') - redirect_to new_user_session_url - else - sign_in_with_notice(current_user) - end - end - - # Signs in user with a nice flash message (if applicable) - # @param current_user [User] user that we want to sign in - def sign_in_with_notice(current_user) - sign_in_and_redirect current_user, event: :authentication - set_flash_message(:notice, :success, kind: 'Twitter') if is_navigational_format? - end - - # Sends a successful OAuth login to the risk endpoint and returns the verdict. - # @param user [User] - # @return [String] the Castle policy action: 'allow', 'challenge' or 'deny' - def evaluate_login(user) - castle.risk( - type: '$login', - status: '$succeeded', - request_token: castle_request_token, - user: { id: user.id, email: user.email } - ).dig(:policy, :action) - rescue Castle::Error - 'allow' - end - - # Reports a failed OAuth login to the filter endpoint. - # @param user [User] - def report_failed_login(user) - castle.filter( - type: '$login', - status: '$failed', - request_token: castle_request_token, - user: { id: user&.id } - ) - rescue Castle::Error - nil - end - end -end diff --git a/app/models/user.rb b/app/models/user.rb index 02c6b72..053502a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,22 +3,5 @@ # User representation class User < ApplicationRecord devise :database_authenticatable, :registerable, - :rememberable, :trackable, :validatable, - :omniauthable, omniauth_providers: %i[twitter] - - class << self - # Finds or creates a user based on the provided OAuth auth data - # @param auth [OmniAuth::AuthHash] - # @return [User] - def find_or_create_for_oauth(auth) - find_or_initialize_by( - provider: auth.provider, - uid: auth.uid - ).tap do |user| - user.password = Devise.friendly_token[0, 20] - user.email = auth.info.email - user.save - end - end - end + :rememberable, :trackable, :validatable end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 8241be0..4ece885 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -5,7 +5,8 @@ %body %nav.navbar = link_to root_path, class: 'brand', id: 'logo' do - %span.brand-dot + %svg.brand-logo{ viewBox: '0 0 158 158', xmlns: 'http://www.w3.org/2000/svg', 'aria-hidden': 'true' } + %path{ fill: 'currentColor', 'fill-rule': 'evenodd', 'clip-rule': 'evenodd', d: 'M79 158c43.63 0 79-35.37 79-79S122.63 0 79 0 0 35.37 0 79s35.37 79 79 79ZM31 57h24v12h12V57h24v12h12V57h24v24c-6.627 0-12 5.373-12 12v12H43V93c0-6.627-5.373-12-12-12V57Z' } Castle %span.text-muted{ style: 'font-weight:400' } demo .nav-links diff --git a/app/views/layouts/devise.html.haml b/app/views/layouts/devise.html.haml index 95af10c..547fef9 100644 --- a/app/views/layouts/devise.html.haml +++ b/app/views/layouts/devise.html.haml @@ -4,11 +4,13 @@ %body .container-narrow - %p.text-center.mb-6 - = link_to root_path, class: 'brand justify-center text-[1.3rem]' do - %span.brand-dot - Castle - %span.text-muted{ style: 'font-weight:400' } demo + .text-center.mb-6 + = link_to root_path, class: 'brand flex-col justify-center gap-3 text-[1.3rem]' do + %svg.brand-logo.brand-logo-lg{ viewBox: '0 0 158 158', xmlns: 'http://www.w3.org/2000/svg', 'aria-hidden': 'true' } + %path{ fill: 'currentColor', 'fill-rule': 'evenodd', 'clip-rule': 'evenodd', d: 'M79 158c43.63 0 79-35.37 79-79S122.63 0 79 0 0 35.37 0 79s35.37 79 79 79ZM31 57h24v12h12V57h24v12h12V57h24v24c-6.627 0-12 5.373-12 12v12H43V93c0-6.627-5.373-12-12-12V57Z' } + %span + Castle + %span.text-muted{ style: 'font-weight:400' } demo = render 'layouts/messages' diff --git a/app/views/main/index.html.haml b/app/views/main/index.html.haml index f008a8e..ce064b7 100644 --- a/app/views/main/index.html.haml +++ b/app/views/main/index.html.haml @@ -28,9 +28,6 @@ — recorded with the non-blocking %code log endpoint. - %li - %strong Twitter/X OAuth login - — the same risk assessment applied to social sign-in. %li %strong Webhooks — incoming Castle webhooks are signature-verified and listed under @@ -48,9 +45,3 @@ (CASTLE_API_SECRET and CASTLE_PK) from the = succeed '.' do %a{ href: 'https://dashboard.castle.io' } Castle dashboard -%p - Twitter/X OAuth is optional: set - %code TWITTER_APP_ID - and - %code TWITTER_SECRET - to enable the social login button. diff --git a/app/views/users/shared/_links.html.haml b/app/views/users/shared/_links.html.haml index ac3705b..8783c54 100644 --- a/app/views/users/shared/_links.html.haml +++ b/app/views/users/shared/_links.html.haml @@ -7,11 +7,3 @@ = link_to t('.sign_up'), new_registration_path(resource_name), class: 'btn btn-alt' - - if devise_mapping.omniauthable? - - resource_class.omniauth_providers.each do |provider| - = button_to t('.sign_in_with', name: OmniAuth::Utils.camelize(provider)), - omniauth_authorize_path(resource_name, - provider, - callback_url: user_twitter_omniauth_callback_url), - method: :post, - class: 'btn btn-alt' diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 315f718..d6b2626 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -13,9 +13,4 @@ config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ config.reset_password_within = 6.hours config.sign_out_via = :delete - config.omniauth( - :twitter, - ENV.fetch('TWITTER_APP_ID', ''), - ENV.fetch('TWITTER_SECRET', '') - ) end diff --git a/config/locales/en/devise.yml b/config/locales/en/devise.yml index 0b8f130..60188e0 100644 --- a/config/locales/en/devise.yml +++ b/config/locales/en/devise.yml @@ -27,9 +27,6 @@ en: subject: "Email Changed" password_change: subject: "Password Changed" - omniauth_callbacks: - failure: "Could not authenticate you from %{kind} because \"%{reason}\"." - success: "Successfully authenticated from %{kind} account." passwords: no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." diff --git a/config/locales/en/users.yml b/config/locales/en/users.yml index be63912..a9d1c1a 100644 --- a/config/locales/en/users.yml +++ b/config/locales/en/users.yml @@ -1,9 +1,5 @@ en: users: - omniauth_callbacks: - twitter: - error: We were unable to sign you in with Twitter right now. - access_denied: Access denied. Please contact the administrator. sessions: new: title: Log in @@ -40,4 +36,3 @@ en: forgot_password: 'Forgot your password?' didnt_receive_conf: "Didn't receive confirmation instructions?" didnt_receive_unlock: "Didn't receive unlock instructions?" - sign_in_with: 'Sign in with %{name}' diff --git a/config/routes.rb b/config/routes.rb index 35719ec..afe05ab 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,7 +7,6 @@ sessions passwords registrations - omniauth_callbacks ].each do |action| devise_controllers[action] = "users/#{action}" end diff --git a/config/tailwind.config.js b/config/tailwind.config.js index e259ff5..8a5e5b9 100644 --- a/config/tailwind.config.js +++ b/config/tailwind.config.js @@ -10,19 +10,19 @@ module.exports = { theme: { extend: { colors: { - bg: '#0b0e14', - 'bg-soft': '#11151f', - surface: '#151a23', - 'surface-2': '#1b2230', - border: '#232b39', - 'border-soft': '#1c2330', - ink: '#e6e9ef', - muted: '#9aa4b2', - accent: '#7c5cff', - 'accent-hover': '#6b4cf0', - success: '#2ecc71', - challenge: '#ffbf47', - danger: '#ff5c7c', + bg: '#f6f8fc', + 'bg-soft': '#eef2f9', + surface: '#ffffff', + 'surface-2': '#eef2fb', + border: '#dde3ee', + 'border-soft': '#e9edf5', + ink: '#0f1729', + muted: '#5b6678', + accent: '#365eed', + 'accent-hover': '#2a4ed1', + success: '#16a34a', + challenge: '#f59e0b', + danger: '#dc2626', }, fontFamily: { sans: ['Inter', 'ui-sans-serif', 'system-ui', 'sans-serif'], @@ -33,7 +33,7 @@ module.exports = { lg: '9px', }, boxShadow: { - card: '0 10px 30px rgba(0, 0, 0, 0.35)', + card: '0 1px 3px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06)', }, }, }, diff --git a/db/migrate/20180424081553_add_omniauth_to_users.rb b/db/migrate/20180424081553_add_omniauth_to_users.rb deleted file mode 100644 index d61dcff..0000000 --- a/db/migrate/20180424081553_add_omniauth_to_users.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -class AddOmniauthToUsers < ActiveRecord::Migration[5.2] - def change - add_column :users, :provider, :string - add_column :users, :uid, :string - end -end diff --git a/db/schema.rb b/db/schema.rb index 5e64da3..5c77576 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -31,8 +31,6 @@ t.string "last_sign_in_ip" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.string "provider" - t.string "uid" t.index ["email"], name: "index_users_on_email", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end diff --git a/docs/screenshots/home.png b/docs/screenshots/home.png index 33126a7..c6b688a 100644 Binary files a/docs/screenshots/home.png and b/docs/screenshots/home.png differ diff --git a/docs/screenshots/login.png b/docs/screenshots/login.png index a2498c5..9c0d809 100644 Binary files a/docs/screenshots/login.png and b/docs/screenshots/login.png differ diff --git a/spec/controllers/users/omniauth_callbacks_controller_spec.rb b/spec/controllers/users/omniauth_callbacks_controller_spec.rb deleted file mode 100644 index 982ff2c..0000000 --- a/spec/controllers/users/omniauth_callbacks_controller_spec.rb +++ /dev/null @@ -1,93 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe Users::OmniauthCallbacksController do - before { request.env['devise.mapping'] = Devise.mappings[:user] } - - let(:user_id) { rand(100) } - - describe '#twitter' do - let(:user) { create(:user, id: user_id) } - - before do - allow(User).to receive(:find_or_create_for_oauth).and_return(user) - end - - context 'when user is valid and persisted' do - let(:risk_args) do - { - type: '$login', - status: '$succeeded', - request_token: nil, - user: { id: user.id, email: user.email } - } - end - - before do - allow(controller.castle).to receive(:risk).and_return(verdict) - get :twitter - end - - context 'when user allowed' do - let(:verdict) { { policy: { action: 'allow' } } } - - it { expect(response).to redirect_to root_path } - it { expect(controller.castle).to have_received(:risk).with(risk_args) } - end - - context 'when user challenged' do - let(:verdict) { { policy: { action: 'challenge' } } } - - it { expect(response).to redirect_to root_path } - it { expect(controller.castle).to have_received(:risk).with(risk_args) } - end - - context 'when user denied' do - let(:verdict) { { policy: { action: 'deny' } } } - let(:error_message) { I18n.t('users.omniauth_callbacks.twitter.access_denied') } - - it { expect(response).to redirect_to new_user_session_path } - it { expect(flash['error']).to eq error_message } - it { expect(controller.castle).to have_received(:risk).with(risk_args) } - end - end - - context 'when Castle raises during risk assessment' do - before do - allow(controller.castle).to receive(:risk).and_raise(Castle::Error) - get :twitter - end - - it 'fails open and signs the user in' do - expect(response).to redirect_to root_path - end - end - - context 'when user is not valid and not persisted' do - let(:user) { build(:user, id: user_id) } - let(:filter_args) do - { type: '$login', status: '$failed', request_token: nil, user: { id: user_id } } - end - - before do - allow(controller.castle).to receive(:filter) - get :twitter - end - - it { expect(response).to redirect_to new_user_registration_path } - it { expect(controller.castle).to have_received(:filter).with(filter_args) } - end - - context 'when user is not persisted and Castle raises' do - let(:user) { build(:user, id: user_id) } - - before do - allow(controller.castle).to receive(:filter).and_raise(Castle::Error) - get :twitter - end - - it 'still redirects without surfacing the error' do - expect(response).to redirect_to new_user_registration_path - end - end - end -end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb deleted file mode 100644 index f5893fd..0000000 --- a/spec/models/user_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe User do - describe '.find_or_create_for_oauth' do - let(:email) { Faker::Internet.email } - let(:auth) do - OmniAuth::AuthHash.new(provider: 'twitter', uid: '12345', info: { email: email }) - end - - context 'when no matching user exists' do - it 'creates a new user' do - expect { described_class.find_or_create_for_oauth(auth) } - .to change(described_class, :count).by(1) - end - - it 'persists the provider, uid and email' do - user = described_class.find_or_create_for_oauth(auth) - - expect(user).to have_attributes( - provider: 'twitter', - uid: '12345', - email: email, - persisted?: true - ) - end - end - - context 'when a user with the same provider and uid exists' do - let!(:existing) do - create(:user, provider: 'twitter', uid: '12345', email: Faker::Internet.email) - end - - it 'does not create another user' do - expect { described_class.find_or_create_for_oauth(auth) } - .not_to change(described_class, :count) - end - - it 'returns the existing record' do - expect(described_class.find_or_create_for_oauth(auth).id).to eq existing.id - end - end - end -end