New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

code0-identities

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code0-identities

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Code0::Identities Build Status GitHub Release Discord

This gem can load and validate external identities

Supported platforms

OAuth:

  • Google
  • Discord
  • Microsoft
  • Github
  • Gitlab

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add code0-identities

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install code0-identities

Usage

You can use predefined Providers to load an identity from for example Discord:


require "code0/identities"

begin

  identity = Code0::Identities::Provider::Discord.new(
    {
      redirect_uri: "http://localhost:8080/redirect",
      client_id: "id",
      client_secret: "xxxx"
    }).load_identity({ code: "a_valid_code" })

rescue Code0::Error => e
  puts "Error occurred while loading the identity", e
  exit!
end

# Then you can use the details from the user
puts identity.provider # = :discord
puts identity.username
puts identity.identifier
# ...

Or you can use a provider with multiple configured providers:


require "code0/identities"

identity_provider = Code0::Identities::IdentityProvider.new

identity_provider.add_provider(:gitlab, my_gitlab_configuration)
identity_provider.add_named_provider(:my_custom_gitlab_provider, :gitlab, my_custom_gitlab_provider_configuration)

# Now you can either use the custom "my_custom_gitlab_provider" provider
# or the "gitlab" provider

identity_provider.load_identity(:gitlab, params)

# or

identity_provider.load_identity(:my_custom_gitlab_provider, params)

We also support passing in a function as a configuration instead of a hash


def get_identity
  provider = Code0::Identities::Provider::Discord.new(-> { fetch_configuration })

  provider.load_identity(params)
end

def fetch_configuration
  # Do some database action, to dynamicly load the configuration
  {
    redirect_uri: "http://localhost:8080/redirect",
    client_id: "some dynamic value",
    client_secret: "xxxx"
  }
end

FAQs

Package last updated on 29 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc