Skip to content
This repository has been archived by the owner on Sep 2, 2019. It is now read-only.

Commit

Permalink
Merge pull request #2 from sankage/master
Browse files Browse the repository at this point in the history
Scopes
  • Loading branch information
mhutter committed May 13, 2016
2 parents 3876431 + d6e3b11 commit 763df42
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
95 changes: 95 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,101 @@ Put in your Client ID and Secret Key of course. You can get them from https://de

For more information on OmniAuth see [the OmniAuth Wiki](https://github.com/intridea/omniauth/wiki).

## Scopes & Authenticated CREST

If you wish to define app-wide scopes for authenticated CREST, add a scope
parameter to the middleware:

```ruby
# Rails:
# config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :crest, 'client_id', 'secret_key',
scope: 'publicData characterLocationRead'
end

# OR

# Rack
use OmniAuth::Builder do
provider :crest, 'client_id', 'secret_key',
scope: 'publicData characterLocationRead'
end
```

### Possible Scopes

As of `2016-05-12`:

* __characterAccountRead__: Read your account subscription status.
* __characterAssetsRead__: Read your asset list.
* __characterBookmarksRead__: List your bookmarks and their coordinates.
* __characterCalendarRead__: Read your calendar events and attendees.
* __characterChatChannelsRead__: List chat channels you own or operate.
* __characterClonesRead__: List your jump clones, implants, attributes, and jump
fatigue timer.
* __characterContactsRead__: Allows access to reading your characters contacts.
* __characterContactsWrite__: Allows applications to add, modify, and delete
contacts for your character.
* __characterContractsRead__: Read your contracts.
* __characterFactionalWarfareRead__: Read your factional warfare statistics.
* __characterFittingsRead__: Allows an application to view all of your
character's saved fits.
* __characterFittingsWrite__: Allows an application to create and delete the
saved fits for your character.
* __characterIndustryJobsRead__: List your industry jobs.
* __characterKillsRead__: Read your kill mails.
* __characterLocationRead__: Allows an application to read your characters real
time location in EVE.
* __characterLoyaltyPointsRead__: List loyalty points your character has for the
different corporations.
* __characterMailRead__: Read your EVE Mail.
* __characterMarketOrdersRead__: Read your market orders.
* __characterMedalsRead__: List your public and private medals.
* __characterNavigationWrite__: Allows an application to set your ships
autopilot destination.
* __characterNotificationsRead__: Receive in-game notifications.
* __characterOpportunitiesRead__: List the opportunities your character has
completed.
* __characterResearchRead__: List your research agents working for you and
research progress.
* __characterSkillsRead__: Read your skills and skill queue.
* __characterStatsRead__: Yearly aggregated stats about your character.
* __characterWalletRead__: Read your wallet status, transaction, and journal
history.
* __corporationAssetRead__: Read your corporation's asset list.
* __corporationBookmarksRead__: List your corporation's bookmarks and their
coordinates.
* __corporationContractsRead__: List your corporation's contracts.
* __corporationFactionalWarfareRead__: Read your corporation's factional warfare
statistics.
* __corporationIndustryJobsRead__: List your corporation's industry jobs.
* __corporationKillsRead__: Read your corporation's kill mails.
* __corporationMarketOrdersRead__: List your corporation's market orders.
* __corporationMedalsRead__: List your corporation's issued medals.
* __corporationMembersRead__: List your corporation's members, their titles, and
roles.
* __corporationShareholdersRead__: List your corporation's shareholders and
their shares.
* __corporationStructuresRead__: List your corporation's structures, outposts,
and starbases.
* __corporationWalletRead__: Read your corporation's wallet status, transaction,
and journal history.
* __fleetRead__: Allows real time reading of your fleet information (members,
ship types, etc.) if you're the boss of the fleet.
* __fleetWrite__: Allows the ability to invite, kick, and update fleet
information if you're the boss of the fleet.
* __publicData__: Allows access to public data.
* __structureVulnUpdate__: Allows updating your structures' vulnerability
timers.

### Per-Request Options

If you want to define the scope on a per-request basis, you can pass it to the
OmniAuth request phase URL, for example:
`/auth/crest?scope=publicData+characterLocationRead`


## Questions

Ask me on Twitter at [@dratir](https://twitter.com/dratir).
Expand Down
12 changes: 12 additions & 0 deletions lib/omniauth/strategies/crest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ class Crest < OmniAuth::Strategies::OAuth2
def raw_info
@raw_info ||= access_token.get('/oauth/verify').parsed
end

def authorize_params
super.tap do |params|
%w[scope].each do |v|
if request.params[v]
params[v.to_sym] = request.params[v]
end
end

params[:scope] ||= ''
end
end
end
end
end

0 comments on commit 763df42

Please sign in to comment.