
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Introducing "UsosAuthLib" a powerful Ruby on Rails library designed to streamline user authentication and seamlessly handle requests through the USOS API. This library simplifies the integration process, allowing developers to effortlessly authenticate users using USOS credentials within their Rails applications. With a focus on security and efficiency, Rails USOS Auth ensures a smooth user experience while providing robust support for USOS API interactions. Elevate your application's functionality by effortlessly incorporating user authentication and USOS API communication with the convenience of Rails USOS Auth.
The USOS API, a cornerstone of academic data access, opens up a world of possibilities for developers seeking to integrate educational information into their applications. Following the OAuth 1.0a workflow as outlined in the official documentation from 'https://apps.usos.edu.pl/developers/api/authorization/', developers can securely implement user authentication and gain authorized access to the wealth of data stored in the USOS system.
The OAuth 1.0a workflow ensures a robust and secure authentication process, safeguarding user credentials while granting seamless access to the USOS API. By adhering to the guidelines provided in the official source, developers can confidently build applications that tap into the extensive educational resources offered by USOS, enriching their projects with academic data in a reliable and user-friendly manner. Explore the possibilities of educational integration through the USOS API and OAuth 1.0a, empowering your applications with a wealth of valuable information.
Add this line to your application's Gemfile:
gem "usos_auth_lib"
And then execute:
$ bundle
Or install it yourself as:
$ gem install usos_auth_lib
Here's an example for adding the configuration to a Rails app in config/initializers/usos_auth_lib.rb
:
UsosAuthLib.configure do |config|
config.api_key = "ENV.fetch('API_KEY', nil)"
config.api_secret = "ENV.fetch('API_SECRET', nil)"
config.usos_base_url = 'https://usosapps.umk.pl/'
config.scopes = 'email|grades'
config.redirect_path = '/usos_auth'
end
config.api_key
-> Consumer api key generated by USOS.
config.api_key
-> Consumer secret key generated by USOS.
config.usos_base_url
-> Your consumer secret key generated by USOS.
config.api_key
-> Your consumer secret key generated by USOS.
config.api_key
-> Your consumer secret key generated by USOS.
The next step is to mount our routes for authorize_user
and callback
to a Rails app in config/routes.rb
:
mount UsosAuthLib::Engine => '/usos_auth_lib'
get '/authorize_user', to: 'usos_auth_lib/usos#authorize_user'
get '/callback', to: 'usos_auth_lib/usos#callback'
get '/authorize_user'
-> replace it with your route or leave it, this is the route used to authorize the user via the USOS API
get '/callback'
-> replace it with your route or leave it, this is the route used to return from USOS, THIS IS NOT THE ROUTE RETURN FROM THE LIBRARY!, this route is the one we added to the configuration
Here's an example for creating a user or obtain it from our database in models/users.rb
:
class User < ApplicationRecord
def self.from_usos(token)
user = User.where(email: token[:email]).first
user = User.create(
email: token[:email],
first_name: token[:first_name],
last_name: token[:last_name],
usos_id: token[:id],
) unless user
user
end
end
Here's an example for callback method in controllers/users_controller.rb
:
def callback
user = User.from_usos(session.delete(:user_data))
session[:current_user_id] = user.id
end
Here's an example for use of handle_request and get_terms_grades method in controllers/users_controller.rb
:
class UsersController < ApplicationController
include UsosAuthCommon
def grades
response = handle_request(session[:access_token], session[:access_token_secret], '/services/grades/terms2?term_ids=2023/24Z|2022/23L')
response_2 = get_terms_grades(session[:access_token], session[:access_token_secret], '2023/24Z|2022/23L')
end
end
In this example, we want to retrieve all grades from the 2023/2024Z and 2022/2023L semester.
When you request a Request Token, you may pass the scopes parameter, which describes the things you want the User to share with you. Many API methods require you to have the access to multiple scopes.
When you ask a User to authorize your Request Token, USOS API will notify the User which scopes your application requires. Choose wisely - users may discard your request if you want too much!
Currently available scope keys:
Source: https://apps.usos.edu.pl/developers/api/authorization/
Contribution directions go here.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that usos_auth_lib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.