GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - svelte-dev/auth-github: A Github Strategy For Svelte Auth

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

3 Commits
3 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
src
src
 
 
static
static
 
 
.editorconfig
.editorconfig
 
 
.eslintignore
.eslintignore
 
 
.eslintrc.cjs
.eslintrc.cjs
 
 
.gitignore
.gitignore
 
 
.npmrc
.npmrc
 
 
.prettierignore
.prettierignore
 
 
.prettierrc
.prettierrc
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
bun.lockb
bun.lockb
 
 
package.json
package.json
 
 
svelte.config.js
svelte.config.js
 
 
tsconfig.json
tsconfig.json
 
 
vite.config.ts
vite.config.ts
 
 

Repository files navigation

Logo

svelte-auth-github strategy

The Github strategy is used to authenticate users against a github account. It extends the OAuth2Strategy.

For more details: https://github.com/willin/svelte-auth

Supported runtimes

Runtime Has Support
Node.js ✅
Cloudflare ✅
Vercel ✅

Usage

Create an OAuth application

Follow the steps on the GitHub documentation to create a new application and get a client ID and secret.

Create the strategy instance

import { GitHubStrategy } from '@svelte-dev/auth-github';

let gitHubStrategy = new GitHubStrategy(
  {
    clientID: 'YOUR_CLIENT_ID',
    clientSecret: 'YOUR_CLIENT_SECRET',
    callbackURL: 'https://example.com/auth/github/callback'
  },
  async ({ accessToken, extraParams, profile }) => {
    // Get the user data from your DB or API using the tokens and profile
    return User.findOrCreate({ email: profile.emails[0].value });
  }
);

auth.use(gitHubStrategy);

Setup your routes

<form action="/auth/sso" method="get">
  <button>Login with SSO</button>
</form>
// routes/auth/github/+server
import { authenticator } from '~/auth.server';
import type { RequestHandler } from './$types';

export const POST: RequestHandler = async (event) => {
  return authenticator.authenticate('github', event);
};
// routes/auth/github/callback/+server
import { authenticator } from '~/auth.server';
import type { PageServerLoad } from './$types';

export const load: PageServerLoad = async ({ event }) => {
  return authenticator.authenticate('github', event, {
    successRedirect: '/dashboard',
    failureRedirect: '/login'
  });
};

赞助 Sponsor

维护者 Owner: Willin Wang

如果您对本项目感兴趣,可以通过以下方式支持我:

  • 关注我的 Github 账号:@willin github
  • 参与 爱发电 计划
  • 支付宝或微信扫码打赏

Donation ways:

  • Github: https://github.com/sponsors/willin
  • Paypal: https://paypal.me/willinwang
  • Alipay or Wechat Pay: QRCode

许可证 License

Apache-2.0

About

A Github Strategy For Svelte Auth

Resources

Readme
License

Code of conduct

Code of conduct

Contributing

Contributing
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.