Skip to content

bsmartlabs/omniauth-bsmart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

OmniAuth bSmart Strategy

Test Gem Version

๐Ÿ”Œ OmniAuth OAuth2 strategy for bSmart accounts.

Features

  • OAuth2 Authorization Code flow using bSmart OAuth endpoints
  • User profile fetch from GET /api/v6/user
  • Automatic fallback to GET /api/v6/me when /user is unavailable
  • Auth hash with normalized uid, info, credentials, and extra.raw_info

Installation

gem 'omniauth-bsmart'

Basic Usage

use OmniAuth::Builder do
  provider :bsmart,
           ENV.fetch('BSMART_CLIENT_ID'),
           ENV.fetch('BSMART_CLIENT_SECRET'),
           scope: 'public'
end

Endpoint Defaults

  • Site: https://www.bsmart.it
  • Authorize URL: /oauth/authorize
  • Token URL: /oauth/token
  • User Info URL: /api/v6/user
  • Fallback User Info URL: /api/v6/me

Optional Overrides

provider :bsmart,
         ENV.fetch('BSMART_CLIENT_ID'),
         ENV.fetch('BSMART_CLIENT_SECRET'),
         client_options: {
           site: 'https://www.bsmart.it',
           authorize_url: '/oauth/authorize',
           token_url: '/oauth/token'
         },
         user_info_url: '/api/v6/user',
         me_url: '/api/v6/me'

Provider App Setup

Create an OAuth application in bSmart and configure your callback URL:

  • Production OAuth base: https://www.bsmart.it/oauth
  • Production API base: https://www.bsmart.it/api/v6

Typical callback path:

  • /auth/bsmart/callback

Auth Hash

{
  "uid": "42",
  "info": {
    "name": "Ada Lovelace",
    "email": "teacher@example.test",
    "first_name": "Ada",
    "last_name": "Lovelace",
    "nickname": "teacher@example.test",
    "image": "https://www.bsmart.it/avatar/42.png",
    "roles": ["teacher"]
  },
  "credentials": {
    "token": "access-token",
    "refresh_token": "refresh-token",
    "expires_at": 1773000000,
    "expires": true,
    "scope": "public"
  },
  "extra": {
    "raw_info": {
      "id": 42,
      "email": "teacher@example.test",
      "name": "Ada",
      "surname": "Lovelace",
      "avatar_url": "https://www.bsmart.it/avatar/42.png",
      "roles": ["teacher"]
    }
  }
}

Development

bundle install
bundle exec rake lint
bundle exec rake test_unit
bundle exec rake test_rails_integration

CI Matrix

  • Ruby: 3.2, 3.3, 3.4, 4.0
  • Rails integration lanes: ~> 7.1.0, ~> 7.2.0, ~> 8.0.0, ~> 8.1.0
  • omniauth-oauth2: 1.8.x, 1.9.x

Release

Tag a release:

git tag vX.Y.Z
git push origin vX.Y.Z

The GitHub Release workflow publishes the gem through RubyGems Trusted Publishing.

License

MIT

About

๐Ÿ”Œ OmniAuth OAuth2 strategy for bSmart accounts.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages