Skip to content

Commit

Permalink
Version 0.1.2 release
Browse files Browse the repository at this point in the history
* Added tests
* Added `coverage` information
* Changed how `%Info{}` is created
* Added `config/test.exs`
* Minor fixes
  • Loading branch information
sobolevn committed Jul 4, 2016
1 parent 2aaa588 commit f634fc5
Show file tree
Hide file tree
Showing 16 changed files with 347 additions and 78 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ erl_crash.dump

#####=== Custom ===#####
doc/
cover/
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
language: elixir

sudo: false

elixir:
- 1.1.0
- 1.2.0

otp_release:
- 17.4
- 18.1

env: MIX_ENV=test

sudo: false # faster builds
script:
- mix dogma
- mix coveralls.travis

notifications:
email: false

script:
- mix compile # --warnings-as-errors
- mix test
- mix dogma
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v0.1.2

* Added tests
* Added `coverage` information
* Changed how `%Info{}` is created

## v0.1.1

* Fixed issues with scopes, images and uid
Expand Down
46 changes: 22 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
# Überauth VK
[![Build Status][travis-img]][travis] [![Hex Version][hex-img]][hex] [![License][license-img]][license]

[travis-img]: https://travis-ci.org/sobolevn/ueberauth_vk.png?branch=master
[travis]: https://travis-ci.org/sobolevn/ueberauth_vk
[hex-img]: https://img.shields.io/hexpm/v/ueberauth_vk.svg
[hex]: https://hex.pm/packages/ueberauth_vk
[license-img]: http://img.shields.io/badge/license-MIT-brightgreen.svg
[license]: http://opensource.org/licenses/MIT
[![Build Status][travis-img]][travis] [![Coverage Status][coverage-img]][coverage] [![Hex Version][hex-img]][hex] [![License][license-img]][license]

> VK OAuth2 strategy for Überauth.
## Installation

1. Setup your application at [VK Developers](https://vk.com/dev).

1. Add `:ueberauth_vk` to your list of dependencies in `mix.exs`:
2. Add `:ueberauth_vk` to your list of dependencies in `mix.exs`:

```elixir
def deps do
# installation via hex:
[{:ueberauth_vk, "~> 0.1.1"}]
[{:ueberauth_vk, "~> 0.1"}]
# if you want to use github:
# [{:ueberauth_vk, github: "sobolevn/ueberauth_vk"}]
end
```

1. Add the strategy to your applications:
3. Add the strategy to your applications:

```elixir
def application do
[applications: [:ueberauth_vk]]
end
```

1. Add VK to your Überauth configuration:
4. Add VK to your Überauth configuration:

```elixir
config :ueberauth, Ueberauth,
Expand All @@ -42,15 +35,15 @@
]
```

1. Update your provider configuration:
5. Update your provider configuration:

```elixir
config :ueberauth, Ueberauth.Strategy.VK.OAuth,
client_id: System.get_env("VK_CLIENT_ID"),
client_secret: System.get_env("VK_CLIENT_SECRET")
```

1. Include the Überauth plug in your controller:
6. Include the Überauth plug in your controller:

```elixir
defmodule MyApp.AuthController do
Expand All @@ -60,7 +53,7 @@
end
```

1. Create the request and callback routes if you haven't already:
7. Create the request and callback routes if you haven't already:

```elixir
scope "/auth", MyApp do
Expand All @@ -71,21 +64,17 @@
end
```

1. You controller needs to implement callbacks to deal with `Ueberauth.Auth` and `Ueberauth.Failure` responses.
8. You controller needs to implement callbacks to deal with `Ueberauth.Auth` and `Ueberauth.Failure` responses.

For an example implementation see the [Überauth Example](https://github.com/ueberauth/ueberauth_example) application.

## Calling

Depending on the configured url you can initial the request through:

/auth/vk
Depending on the configured url you can initial the request through: `/auth/vk`

Or with options:
Or with options: `/auth/vk?scope=friends,video,offline`

/auth/vk?scope=friends,video,offline

By default the requested scope is "public_profile". Scope can be configured either explicitly as a `scope` query value on the request path or in your configuration:
By default the requested scope is `"public_profile"`. Scope can be configured either explicitly as a `scope` query value on the request path or in your configuration:

```elixir
config :ueberauth, Ueberauth,
Expand All @@ -108,4 +97,13 @@ See [VK API Method Reference > User](https://vk.com/dev/users.get) for full list

## License

Please see [LICENSE](https://github.com/ueberauth/ueberauth_vk/blob/master/LICENSE) for licensing details.
MIT. Please see [LICENSE](https://github.com/ueberauth/ueberauth_vk/blob/master/LICENSE) for licensing details.

[travis-img]: https://img.shields.io/travis/sobolevn/ueberauth_vk/master.svg
[travis]: https://travis-ci.org/sobolevn/ueberauth_vk
[coverage-img]: https://coveralls.io/repos/github/sobolevn/ueberauth_vk/badge.svg?branch=master
[coverage]: https://coveralls.io/github/sobolevn/ueberauth_vk?branch=master
[hex-img]: https://img.shields.io/hexpm/v/ueberauth_vk.svg
[hex]: https://hex.pm/packages/ueberauth_vk
[license-img]: http://img.shields.io/badge/license-MIT-brightgreen.svg
[license]: http://opensource.org/licenses/MIT
19 changes: 19 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config

# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
# file won't be loaded nor affect the parent project. For this reason,
# if you want to provide default values for your application for
# 3rd-party users, it should be done in your "mix.exs" file.

# It is also possible to import configuration files, relative to this
# directory. For example, you can emulate configuration per environment
# by uncommenting the line below and defining dev.exs, test.exs and such.
# Configuration from the imported file will override the ones defined
# here (which is why it is important to import them last).
#
# import_config "#{Mix.env}.exs"
# import_config "#{Mix.env}.exs"

if Mix.env == :test, do: import_config "test.exs"
11 changes: 11 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use Mix.Config

config :ueberauth, Ueberauth,
providers: [
vk: { Ueberauth.Strategy.VK, [] },
]

config :ueberauth, Ueberauth.Strategy.VK.OAuth,
client_id: "appid",
client_secret: "secret",
redirect_uri: "/callback"
11 changes: 7 additions & 4 deletions lib/ueberauth/strategy/vk.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ defmodule Ueberauth.Strategy.VK do
|> maybe_replace_param(conn, "auth_type", :auth_type)
|> maybe_replace_param(conn, "scope", :default_scope)
|> maybe_replace_param(conn, "display", :default_display)
|> Enum.filter(fn {k,_v} -> Enum.member?(allowed_params, k) end)
|> Enum.map(fn {k,v} -> {String.to_existing_atom(k), v} end)
|> Enum.filter(fn {k, _} -> Enum.member?(allowed_params, k) end)
|> Enum.map(fn {k, v} -> {String.to_existing_atom(k), v} end)
|> Keyword.put(:redirect_uri, callback_url(conn))
|> Ueberauth.Strategy.VK.OAuth.authorize_url!

Expand Down Expand Up @@ -107,9 +107,10 @@ defmodule Ueberauth.Strategy.VK do
first_name: user["first_name"],
last_name: user["last_name"],
email: token.other_params["email"],
name: user["name"],
name: fetch_name(user),
image: fetch_image(user),
location: user["location"],
location: user["city"],
description: user["about"],
urls: %{
vk: "https://vk.com/" <> to_string(user["uid"])
}
Expand All @@ -129,6 +130,8 @@ defmodule Ueberauth.Strategy.VK do
}
end

defp fetch_name(user), do: user["first_name"] <> " " <> user["last_name"]

defp fetch_image(user) do
user_photo =
user
Expand Down
63 changes: 41 additions & 22 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,68 @@ defmodule UeberauthVK.Mixfile do
@url "https://github.com/sobolevn/ueberauth_vk"

def project do
[app: :ueberauth_vk,
version: @version,
name: "Ueberauth VK Strategy",
package: package,
elixir: "~> 1.1",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
source_url: @url,
homepage_url: @url,
description: description,
deps: deps,
docs: docs]
[
app: :ueberauth_vk,
version: @version,
name: "Ueberauth VK Strategy",
package: package,
elixir: "~> 1.1",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
source_url: @url,
homepage_url: @url,
description: description,
deps: deps,
docs: docs,

# Test coverage:
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [
"coveralls": :test,
"coveralls.detail": :test,
"coveralls.post": :test,
"coveralls.html": :test,
],
]
end

def application do
[applications: [:logger, :oauth2, :ueberauth]]
end

defp deps do
[{:ueberauth, "~> 0.2"},
[
# Auth:
{:ueberauth, "~> 0.2"},
{:oauth2, "~> 0.5"},

# Tests:
{:exvcr, "~> 0.7", only: :test},
{:excoveralls, "~> 0.5", only: :test},

# Docs:
{:ex_doc, "~> 0.1", only: :dev},
{:earmark, ">= 0.0.0", only: :dev},
{:dogma, ">= 0.0.0", only: [:dev, :test]}]
# {:foobar, path: "path/to/foobar"}
end

defp docs do
[extras: docs_extras, main: "extra-readme"]
# Lint:
{:dogma, "~> 0.1", only: [:dev, :test]},
]
end

defp docs_extras do
["README.md"]
defp docs do
[extras: ["README.md"], main: "readme"]
end

defp description do
"An Uberauth strategy for VK authentication."
end

defp package do
[files: ["lib", "mix.exs", "README.md", "LICENSE"],
[
files: ["lib", "mix.exs", "README.md", "LICENSE"],
maintainers: ["Sobolev Nikita"],
licenses: ["MIT"],
links: %{"GitHub": @url}]
links: %{"GitHub": @url},
]
end
end
34 changes: 20 additions & 14 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
%{"certifi": {:hex, :certifi, "0.1.1"},
"dogma": {:hex, :dogma, "0.0.11"},
"earmark": {:hex, :earmark, "0.1.19"},
"ex_doc": {:hex, :ex_doc, "0.10.0"},
"hackney": {:hex, :hackney, "1.4.4"},
"httpoison": {:hex, :httpoison, "0.8.0"},
"idna": {:hex, :idna, "1.0.2"},
"mimerl": {:hex, :mimerl, "1.0.0"},
"mimetype_parser": {:hex, :mimetype_parser, "0.1.0"},
"oauth2": {:hex, :oauth2, "0.5.0"},
"plug": {:hex, :plug, "1.1.0"},
"poison": {:hex, :poison, "1.5.0"},
"ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.5"},
"ueberauth": {:hex, :ueberauth, "0.2.0"}}
%{"certifi": {:hex, :certifi, "0.1.1", "7fd287d0fea2d65e99f5bef3b8573fa46f4310078709be969adcbc93a580ee73", [:rebar], []},
"dogma": {:hex, :dogma, "0.1.7", "927f76a89a809db96e0983b922fc899f601352690aefa123529b8aa0c45123b2", [:mix], [{:poison, ">= 1.0.0", [hex: :poison, optional: false]}]},
"earmark": {:hex, :earmark, "0.1.19", "ffec54f520a11b711532c23d8a52b75a74c09697062d10613fa2dbdf8a9db36e", [:mix], []},
"ex_doc": {:hex, :ex_doc, "0.10.0", "f49c237250b829df986486b38f043e6f8e19d19b41101987f7214543f75947ec", [:mix], [{:earmark, "~> 0.1.17 or ~> 0.2", [hex: :earmark, optional: true]}]},
"exactor": {:hex, :exactor, "2.2.0", "2a7418b82d974fe8276edd62c1facf4a9dc06339cdf11b5dcd10359e107fe5c3", [:mix], []},
"excoveralls": {:hex, :excoveralls, "0.5.5", "d97b6fc7aa59c5f04f2fa7ec40fc0b7555ceea2a5f7e7c442aad98ddd7f79002", [:mix], [{:hackney, ">= 0.12.0", [hex: :hackney, optional: false]}, {:exjsx, "~> 3.0", [hex: :exjsx, optional: false]}]},
"exjsx": {:hex, :exjsx, "3.2.0", "7136cc739ace295fc74c378f33699e5145bead4fdc1b4799822d0287489136fb", [:mix], [{:jsx, "~> 2.6.2", [hex: :jsx, optional: false]}]},
"exvcr": {:hex, :exvcr, "0.7.4", "9e7b4cf5f91ecfabdac7a375610633b28288795503bdff0eb8763c275d367657", [:mix], [{:meck, "~> 0.8.3", [hex: :meck, optional: false]}, {:httpotion, "~> 2.1", [hex: :httpotion, optional: true]}, {:httpoison, "~> 0.8", [hex: :httpoison, optional: true]}, {:exjsx, "~> 3.2", [hex: :exjsx, optional: false]}, {:exactor, "~> 2.2", [hex: :exactor, optional: false]}]},
"hackney": {:hex, :hackney, "1.4.4", "c4e9fd8d77c79f03c09712500780077aeb6cdfe7bab3f4c56cb87d337a7526d7", [:rebar3], [{:ssl_verify_hostname, "1.0.5", [hex: :ssl_verify_hostname, optional: false]}, {:mimerl, "1.0.0", [hex: :mimerl, optional: false]}, {:idna, "1.0.2", [hex: :idna, optional: false]}, {:certifi, "0.1.1", [hex: :certifi, optional: false]}]},
"httpoison": {:hex, :httpoison, "0.8.0", "52a958d40b2aa46da418cdf6d8dfd82ba83e94d5e60920dfa5f40c05b34fe073", [:mix], [{:hackney, "~> 1.4.4", [hex: :hackney, optional: false]}]},
"idna": {:hex, :idna, "1.0.2", "397e3d001c002319da75759b0a81156bf11849c71d565162436d50020cb7265e", [:make], []},
"jsx": {:hex, :jsx, "2.6.2", "213721e058da0587a4bce3cc8a00ff6684ced229c8f9223245c6ff2c88fbaa5a", [:mix, :rebar], []},
"meck": {:hex, :meck, "0.8.4", "59ca1cd971372aa223138efcf9b29475bde299e1953046a0c727184790ab1520", [:rebar, :make], []},
"mimerl": {:hex, :mimerl, "1.0.0", "b9813e0fa1019420da8c8001748d7c34791fd49464cb28762bc22638b1ff6198", [:rebar3], []},
"mimetype_parser": {:hex, :mimetype_parser, "0.1.0", "069fcf6aa98b1eb90d879b3035f3392acecef1ee212ddc59fa930a6cc15d85e3", [:mix], []},
"oauth2": {:hex, :oauth2, "0.5.0", "bb46ad20f060540c2726c993b4661a9f89b7acec5568ceae7009560358fbc765", [:mix], [{:poison, "~> 1.3", [hex: :poison, optional: false]}, {:mimetype_parser, "~> 0.1", [hex: :mimetype_parser, optional: false]}, {:httpoison, "~> 0.7", [hex: :httpoison, optional: false]}]},
"plug": {:hex, :plug, "1.1.0", "69078a481549b81e879e169fbe099a509baf8d6a793db757f39f86258f91db07", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}]},
"poison": {:hex, :poison, "1.5.2", "560bdfb7449e3ddd23a096929fb9fc2122f709bcc758b2d5d5a5c7d0ea848910", [:mix], []},
"ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.5", "2e73e068cd6393526f9fa6d399353d7c9477d6886ba005f323b592d389fb47be", [:make], []},
"ueberauth": {:hex, :ueberauth, "0.2.0", "9160c601b468c6692462a56be7ad8890d1a2d84519d7d9c4541da5b07d6495e1", [:mix], [{:plug, "~> 1.0", [hex: :plug, optional: false]}]}}
Loading

0 comments on commit f634fc5

Please sign in to comment.