diff --git a/.formatter.exs b/.formatter.exs
index 54b83868..53d5a19f 100644
--- a/.formatter.exs
+++ b/.formatter.exs
@@ -8,6 +8,7 @@ spark_locals_without_parens = [
auth_method: 1,
authorization_params: 1,
authorize_url: 1,
+ base_url: 1,
client_authentication_method: 1,
client_id: 1,
client_secret: 1,
diff --git a/config/dev.exs b/config/dev.exs
index e555bd0f..11403122 100644
--- a/config/dev.exs
+++ b/config/dev.exs
@@ -31,7 +31,7 @@ config :ash_authentication,
client_id: System.get_env("OAUTH2_CLIENT_ID"),
redirect_uri: "http://localhost:4000/auth",
client_secret: System.get_env("OAUTH2_CLIENT_SECRET"),
- site: System.get_env("OAUTH2_SITE"),
+ base_url: System.get_env("OAUTH2_SITE"),
authorize_url: "#{System.get_env("OAUTH2_SITE")}/authorize",
token_url: "#{System.get_env("OAUTH2_SITE")}/oauth/token",
user_url: "#{System.get_env("OAUTH2_SITE")}/userinfo"
@@ -40,7 +40,7 @@ config :ash_authentication,
client_id: System.get_env("OAUTH2_CLIENT_ID"),
redirect_uri: "http://localhost:4000/auth",
client_secret: System.get_env("OAUTH2_CLIENT_SECRET"),
- site: System.get_env("OAUTH2_SITE")
+ base_url: System.get_env("OAUTH2_SITE")
],
github: [
client_id: System.get_env("GITHUB_CLIENT_ID"),
@@ -52,7 +52,7 @@ config :ash_authentication,
client_id: System.get_env("OAUTH2_CLIENT_ID"),
client_secret: System.get_env("OAUTH2_CLIENT_SECRET"),
redirect_uri: "http://localhost:4000/auth",
- site: System.get_env("OAUTH2_SITE"),
+ base_url: System.get_env("OAUTH2_SITE"),
token_url: "#{System.get_env("OAUTH2_SITE")}/oauth/token"
]
],
diff --git a/config/test.exs b/config/test.exs
index 81daf300..15156b58 100644
--- a/config/test.exs
+++ b/config/test.exs
@@ -21,7 +21,7 @@ config :ash_authentication,
client_id: "pretend client id",
redirect_uri: "http://localhost:4000/auth",
client_secret: "pretend client secret",
- site: "https://example.com/",
+ base_url: "https://example.com/",
authorize_url: "https://example.com/authorize",
token_url: "https://example.com/oauth/token",
user_url: "https://example.com/userinfo"
diff --git a/documentation/dsls/DSL:-AshAuthentication.Strategy.Auth0.cheatmd b/documentation/dsls/DSL:-AshAuthentication.Strategy.Auth0.cheatmd
index 8debaf34..09029471 100644
--- a/documentation/dsls/DSL:-AshAuthentication.Strategy.Auth0.cheatmd
+++ b/documentation/dsls/DSL:-AshAuthentication.Strategy.Auth0.cheatmd
@@ -63,7 +63,7 @@ The following defaults are applied:
end
```
-* `:site` - Required. The base URL of the OAuth2 server - including the leading protocol
+* `:base_url` - The base URL of the OAuth2 server - including the leading protocol
(ie `https://`).
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -72,13 +72,15 @@ The following defaults are applied:
Example:
```elixir
- site fn _, resource ->
+ base_url fn _, resource ->
:my_app
|> Application.get_env(resource, [])
|> Keyword.fetch(:oauth_site)
end
```
+* `:site` - Deprecated: Use `base_url` instead.
+
* `:auth_method` - The authentication strategy used, optional. If not set, no
authentication will be used during the access token request. The
value may be one of the following:
@@ -331,9 +333,9 @@ end
-
+
- site
+ authorize_url
*
@@ -346,8 +348,9 @@ end
|
- The base URL of the OAuth2 server - including the leading protocol
-(ie `https://`).
+ The API url to the OAuth2 authorize endpoint.
+
+Relative to the value of `site`.
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -359,11 +362,7 @@ information.
Example:
```elixir
-site fn _, resource ->
- :my_app
- |> Application.get_env(resource, [])
- |> Keyword.fetch(:oauth_site)
-end
+authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
```
|
@@ -371,9 +370,9 @@ end
-
+
- authorize_url
+ token_url
*
@@ -386,7 +385,7 @@ end
|
- The API url to the OAuth2 authorize endpoint.
+ The API url to access the token endpoint.
Relative to the value of `site`.
@@ -400,7 +399,7 @@ information.
Example:
```elixir
-authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
+token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
```
|
@@ -408,9 +407,9 @@ authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
-
+
- token_url
+ user_url
*
@@ -423,7 +422,7 @@ authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
|
- The API url to access the token endpoint.
+ The API url to access the user endpoint.
Relative to the value of `site`.
@@ -437,7 +436,7 @@ information.
Example:
```elixir
-token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
+user_url fn _, _ -> {:ok, "https://example.com/userinfo"} end
```
|
@@ -445,9 +444,9 @@ token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
-
+
- user_url
+ redirect_uri
*
@@ -460,9 +459,14 @@ token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
|
- The API url to access the user endpoint.
+ The callback URI base.
-Relative to the value of `site`.
+Not the whole URI back to the callback endpoint, but the URI to your
+`AuthPlug`. We can generate the rest.
+
+Whilst not particularly secret, it seemed prudent to allow this to be
+configured dynamically so that you can use different URIs for
+different environments.
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -471,24 +475,17 @@ See the module documentation for `AshAuthentication.Secret` for more
information.
-Example:
-
-```elixir
-user_url fn _, _ -> {:ok, "https://example.com/userinfo"} end
-```
-
|
-
+
- redirect_uri
+ base_url
- *
-
+
|
(any, any -> any) | module | String.t
@@ -497,14 +494,8 @@ user_url fn _, _ -> {:ok, "https://example.com/userinfo"} end
|
- The callback URI base.
-
-Not the whole URI back to the callback endpoint, but the URI to your
-`AuthPlug`. We can generate the rest.
-
-Whilst not particularly secret, it seemed prudent to allow this to be
-configured dynamically so that you can use different URIs for
-different environments.
+ The base URL of the OAuth2 server - including the leading protocol
+(ie `https://`).
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -513,6 +504,36 @@ See the module documentation for `AshAuthentication.Secret` for more
information.
+Example:
+
+```elixir
+base_url fn _, resource ->
+ :my_app
+ |> Application.get_env(resource, [])
+ |> Keyword.fetch(:oauth_site)
+end
+```
+
+ |
+
+
+
+
+
+
+ site
+
+
+
+ |
+
+ (any, any -> any) | module | String.t
+ |
+
+
+ |
+
+ Deprecated: Use `base_url` instead.
|
diff --git a/documentation/dsls/DSL:-AshAuthentication.Strategy.Github.cheatmd b/documentation/dsls/DSL:-AshAuthentication.Strategy.Github.cheatmd
index b482805e..a9d28fc1 100644
--- a/documentation/dsls/DSL:-AshAuthentication.Strategy.Github.cheatmd
+++ b/documentation/dsls/DSL:-AshAuthentication.Strategy.Github.cheatmd
@@ -31,7 +31,7 @@ in our documentation.
The following defaults are applied:
- * `:site` is set to `"https://api.github.com"`.
+ * `:base_url` is set to `"https://api.github.com"`.
* `:authorize_url` is set to `"https://github.com/login/oauth/authorize"`.
* `:token_url` is set to `"https://github.com/login/oauth/access_token"`.
* `:user_url` is set to `"/user"`.
@@ -64,7 +64,7 @@ The following defaults are applied:
end
```
-* `:site` - Required. The base URL of the OAuth2 server - including the leading protocol
+* `:base_url` - The base URL of the OAuth2 server - including the leading protocol
(ie `https://`).
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -73,13 +73,15 @@ The following defaults are applied:
Example:
```elixir
- site fn _, resource ->
+ base_url fn _, resource ->
:my_app
|> Application.get_env(resource, [])
|> Keyword.fetch(:oauth_site)
end
```
+* `:site` - Deprecated: Use `base_url` instead.
+
* `:auth_method` - The authentication strategy used, optional. If not set, no
authentication will be used during the access token request. The
value may be one of the following:
@@ -229,7 +231,7 @@ in our documentation.
The following defaults are applied:
-* `:site` is set to `"https://api.github.com"`.
+* `:base_url` is set to `"https://api.github.com"`.
* `:authorize_url` is set to `"https://github.com/login/oauth/authorize"`.
* `:token_url` is set to `"https://github.com/login/oauth/access_token"`.
* `:user_url` is set to `"/user"`.
@@ -334,9 +336,9 @@ end
-
+
- site
+ authorize_url
*
@@ -349,8 +351,9 @@ end
|
- The base URL of the OAuth2 server - including the leading protocol
-(ie `https://`).
+ The API url to the OAuth2 authorize endpoint.
+
+Relative to the value of `site`.
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -362,11 +365,7 @@ information.
Example:
```elixir
-site fn _, resource ->
- :my_app
- |> Application.get_env(resource, [])
- |> Keyword.fetch(:oauth_site)
-end
+authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
```
|
@@ -374,9 +373,9 @@ end
-
+
- authorize_url
+ token_url
*
@@ -389,7 +388,7 @@ end
|
- The API url to the OAuth2 authorize endpoint.
+ The API url to access the token endpoint.
Relative to the value of `site`.
@@ -403,7 +402,7 @@ information.
Example:
```elixir
-authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
+token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
```
|
@@ -411,9 +410,9 @@ authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
-
+
- token_url
+ user_url
*
@@ -426,7 +425,7 @@ authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
|
- The API url to access the token endpoint.
+ The API url to access the user endpoint.
Relative to the value of `site`.
@@ -440,7 +439,7 @@ information.
Example:
```elixir
-token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
+user_url fn _, _ -> {:ok, "https://example.com/userinfo"} end
```
|
@@ -448,9 +447,9 @@ token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
-
+
- user_url
+ redirect_uri
*
@@ -463,9 +462,14 @@ token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
|
- The API url to access the user endpoint.
+ The callback URI base.
-Relative to the value of `site`.
+Not the whole URI back to the callback endpoint, but the URI to your
+`AuthPlug`. We can generate the rest.
+
+Whilst not particularly secret, it seemed prudent to allow this to be
+configured dynamically so that you can use different URIs for
+different environments.
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -474,24 +478,17 @@ See the module documentation for `AshAuthentication.Secret` for more
information.
-Example:
-
-```elixir
-user_url fn _, _ -> {:ok, "https://example.com/userinfo"} end
-```
-
|
-
+
- redirect_uri
+ base_url
- *
-
+
|
(any, any -> any) | module | String.t
@@ -500,14 +497,8 @@ user_url fn _, _ -> {:ok, "https://example.com/userinfo"} end
|
- The callback URI base.
-
-Not the whole URI back to the callback endpoint, but the URI to your
-`AuthPlug`. We can generate the rest.
-
-Whilst not particularly secret, it seemed prudent to allow this to be
-configured dynamically so that you can use different URIs for
-different environments.
+ The base URL of the OAuth2 server - including the leading protocol
+(ie `https://`).
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -516,6 +507,36 @@ See the module documentation for `AshAuthentication.Secret` for more
information.
+Example:
+
+```elixir
+base_url fn _, resource ->
+ :my_app
+ |> Application.get_env(resource, [])
+ |> Keyword.fetch(:oauth_site)
+end
+```
+
+ |
+
+
+
+
+
+
+ site
+
+
+
+ |
+
+ (any, any -> any) | module | String.t
+ |
+
+
+ |
+
+ Deprecated: Use `base_url` instead.
|
diff --git a/documentation/dsls/DSL:-AshAuthentication.Strategy.Google.cheatmd b/documentation/dsls/DSL:-AshAuthentication.Strategy.Google.cheatmd
index 4993affe..9bab1894 100644
--- a/documentation/dsls/DSL:-AshAuthentication.Strategy.Google.cheatmd
+++ b/documentation/dsls/DSL:-AshAuthentication.Strategy.Google.cheatmd
@@ -32,7 +32,7 @@ for Google setup details.
The following defaults are applied:
- * `:site` is set to `"https://www.googleapis.com"`.
+ * `:base_url` is set to `"https://www.googleapis.com"`.
* `:authorize_url` is set to `"https://accounts.google.com/o/oauth2/v2/auth"`.
* `:token_url` is set to `"/oauth2/v4/token"`.
* `:user_url` is set to `"/oauth2/v3/userinfo"`.
@@ -64,7 +64,7 @@ The following defaults are applied:
end
```
-* `:site` - Required. The base URL of the OAuth2 server - including the leading protocol
+* `:base_url` - The base URL of the OAuth2 server - including the leading protocol
(ie `https://`).
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -73,13 +73,15 @@ The following defaults are applied:
Example:
```elixir
- site fn _, resource ->
+ base_url fn _, resource ->
:my_app
|> Application.get_env(resource, [])
|> Keyword.fetch(:oauth_site)
end
```
+* `:site` - Deprecated: Use `base_url` instead.
+
* `:auth_method` - The authentication strategy used, optional. If not set, no
authentication will be used during the access token request. The
value may be one of the following:
@@ -229,7 +231,7 @@ for Google setup details.
The following defaults are applied:
-* `:site` is set to `"https://www.googleapis.com"`.
+* `:base_url` is set to `"https://www.googleapis.com"`.
* `:authorize_url` is set to `"https://accounts.google.com/o/oauth2/v2/auth"`.
* `:token_url` is set to `"/oauth2/v4/token"`.
* `:user_url` is set to `"/oauth2/v3/userinfo"`.
@@ -333,9 +335,9 @@ end
-
+
- site
+ authorize_url
*
@@ -348,8 +350,9 @@ end
|
- The base URL of the OAuth2 server - including the leading protocol
-(ie `https://`).
+ The API url to the OAuth2 authorize endpoint.
+
+Relative to the value of `site`.
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -361,11 +364,7 @@ information.
Example:
```elixir
-site fn _, resource ->
- :my_app
- |> Application.get_env(resource, [])
- |> Keyword.fetch(:oauth_site)
-end
+authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
```
|
@@ -373,9 +372,9 @@ end
-
+
- authorize_url
+ token_url
*
@@ -388,7 +387,7 @@ end
|
- The API url to the OAuth2 authorize endpoint.
+ The API url to access the token endpoint.
Relative to the value of `site`.
@@ -402,7 +401,7 @@ information.
Example:
```elixir
-authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
+token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
```
|
@@ -410,9 +409,9 @@ authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
-
+
- token_url
+ user_url
*
@@ -425,7 +424,7 @@ authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
|
- The API url to access the token endpoint.
+ The API url to access the user endpoint.
Relative to the value of `site`.
@@ -439,7 +438,7 @@ information.
Example:
```elixir
-token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
+user_url fn _, _ -> {:ok, "https://example.com/userinfo"} end
```
|
@@ -447,9 +446,9 @@ token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
-
+
- user_url
+ redirect_uri
*
@@ -462,9 +461,14 @@ token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
|
- The API url to access the user endpoint.
+ The callback URI base.
-Relative to the value of `site`.
+Not the whole URI back to the callback endpoint, but the URI to your
+`AuthPlug`. We can generate the rest.
+
+Whilst not particularly secret, it seemed prudent to allow this to be
+configured dynamically so that you can use different URIs for
+different environments.
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -473,24 +477,17 @@ See the module documentation for `AshAuthentication.Secret` for more
information.
-Example:
-
-```elixir
-user_url fn _, _ -> {:ok, "https://example.com/userinfo"} end
-```
-
|
-
+
- redirect_uri
+ base_url
- *
-
+
|
(any, any -> any) | module | String.t
@@ -499,14 +496,8 @@ user_url fn _, _ -> {:ok, "https://example.com/userinfo"} end
|
- The callback URI base.
-
-Not the whole URI back to the callback endpoint, but the URI to your
-`AuthPlug`. We can generate the rest.
-
-Whilst not particularly secret, it seemed prudent to allow this to be
-configured dynamically so that you can use different URIs for
-different environments.
+ The base URL of the OAuth2 server - including the leading protocol
+(ie `https://`).
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -515,6 +506,36 @@ See the module documentation for `AshAuthentication.Secret` for more
information.
+Example:
+
+```elixir
+base_url fn _, resource ->
+ :my_app
+ |> Application.get_env(resource, [])
+ |> Keyword.fetch(:oauth_site)
+end
+```
+
+ |
+
+
+
+
+
+
+ site
+
+
+
+ |
+
+ (any, any -> any) | module | String.t
+ |
+
+
+ |
+
+ Deprecated: Use `base_url` instead.
|
diff --git a/documentation/dsls/DSL:-AshAuthentication.Strategy.OAuth2.cheatmd b/documentation/dsls/DSL:-AshAuthentication.Strategy.OAuth2.cheatmd
index d1215ed2..b85d251e 100644
--- a/documentation/dsls/DSL:-AshAuthentication.Strategy.OAuth2.cheatmd
+++ b/documentation/dsls/DSL:-AshAuthentication.Strategy.OAuth2.cheatmd
@@ -243,7 +243,7 @@ OAuth2 authentication
end
```
-* `:site` - Required. The base URL of the OAuth2 server - including the leading protocol
+* `:base_url` - The base URL of the OAuth2 server - including the leading protocol
(ie `https://`).
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -252,13 +252,15 @@ OAuth2 authentication
Example:
```elixir
- site fn _, resource ->
+ base_url fn _, resource ->
:my_app
|> Application.get_env(resource, [])
|> Keyword.fetch(:oauth_site)
end
```
+* `:site` - Deprecated: Use `base_url` instead.
+
* `:auth_method` - The authentication strategy used, optional. If not set, no
authentication will be used during the access token request. The
value may be one of the following:
@@ -491,9 +493,9 @@ end
-
+
- site
+ authorize_url
*
@@ -506,8 +508,9 @@ end
|
- The base URL of the OAuth2 server - including the leading protocol
-(ie `https://`).
+ The API url to the OAuth2 authorize endpoint.
+
+Relative to the value of `site`.
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -519,11 +522,7 @@ information.
Example:
```elixir
-site fn _, resource ->
- :my_app
- |> Application.get_env(resource, [])
- |> Keyword.fetch(:oauth_site)
-end
+authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
```
|
@@ -531,9 +530,9 @@ end
-
+
- authorize_url
+ token_url
*
@@ -546,7 +545,7 @@ end
|
- The API url to the OAuth2 authorize endpoint.
+ The API url to access the token endpoint.
Relative to the value of `site`.
@@ -560,7 +559,7 @@ information.
Example:
```elixir
-authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
+token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
```
|
@@ -568,9 +567,9 @@ authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
-
+
- token_url
+ user_url
*
@@ -583,7 +582,7 @@ authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
|
- The API url to access the token endpoint.
+ The API url to access the user endpoint.
Relative to the value of `site`.
@@ -597,7 +596,7 @@ information.
Example:
```elixir
-token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
+user_url fn _, _ -> {:ok, "https://example.com/userinfo"} end
```
|
@@ -605,9 +604,9 @@ token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
-
+
- user_url
+ redirect_uri
*
@@ -620,9 +619,14 @@ token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
|
- The API url to access the user endpoint.
+ The callback URI base.
-Relative to the value of `site`.
+Not the whole URI back to the callback endpoint, but the URI to your
+`AuthPlug`. We can generate the rest.
+
+Whilst not particularly secret, it seemed prudent to allow this to be
+configured dynamically so that you can use different URIs for
+different environments.
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -631,24 +635,17 @@ See the module documentation for `AshAuthentication.Secret` for more
information.
-Example:
-
-```elixir
-user_url fn _, _ -> {:ok, "https://example.com/userinfo"} end
-```
-
|
-
+
- redirect_uri
+ base_url
- *
-
+
|
(any, any -> any) | module | String.t
@@ -657,14 +654,8 @@ user_url fn _, _ -> {:ok, "https://example.com/userinfo"} end
|
- The callback URI base.
-
-Not the whole URI back to the callback endpoint, but the URI to your
-`AuthPlug`. We can generate the rest.
-
-Whilst not particularly secret, it seemed prudent to allow this to be
-configured dynamically so that you can use different URIs for
-different environments.
+ The base URL of the OAuth2 server - including the leading protocol
+(ie `https://`).
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -673,6 +664,36 @@ See the module documentation for `AshAuthentication.Secret` for more
information.
+Example:
+
+```elixir
+base_url fn _, resource ->
+ :my_app
+ |> Application.get_env(resource, [])
+ |> Keyword.fetch(:oauth_site)
+end
+```
+
+ |
+
+
+
+
+
+
+ site
+
+
+
+ |
+
+ (any, any -> any) | module | String.t
+ |
+
+
+ |
+
+ Deprecated: Use `base_url` instead.
|
diff --git a/documentation/dsls/DSL:-AshAuthentication.Strategy.Oidc.cheatmd b/documentation/dsls/DSL:-AshAuthentication.Strategy.Oidc.cheatmd
index 42d8ba96..cbe16861 100644
--- a/documentation/dsls/DSL:-AshAuthentication.Strategy.Oidc.cheatmd
+++ b/documentation/dsls/DSL:-AshAuthentication.Strategy.Oidc.cheatmd
@@ -79,7 +79,7 @@ all the same configuration options should you need them.
end
```
-* `:site` - Required. The base URL of the OAuth2 server - including the leading protocol
+* `:base_url` - The base URL of the OAuth2 server - including the leading protocol
(ie `https://`).
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -88,13 +88,15 @@ all the same configuration options should you need them.
Example:
```elixir
- site fn _, resource ->
+ base_url fn _, resource ->
:my_app
|> Application.get_env(resource, [])
|> Keyword.fetch(:oauth_site)
end
```
+* `:site` - Deprecated: Use `base_url` instead.
+
* `:auth_method` - The authentication strategy used, optional. If not set, no
authentication will be used during the access token request. The
value may be one of the following:
@@ -355,9 +357,9 @@ end
-
+
- site
+ authorize_url
*
@@ -370,8 +372,9 @@ end
|
- The base URL of the OAuth2 server - including the leading protocol
-(ie `https://`).
+ The API url to the OAuth2 authorize endpoint.
+
+Relative to the value of `site`.
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -383,11 +386,7 @@ information.
Example:
```elixir
-site fn _, resource ->
- :my_app
- |> Application.get_env(resource, [])
- |> Keyword.fetch(:oauth_site)
-end
+authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
```
|
@@ -395,9 +394,9 @@ end
-
+
- authorize_url
+ token_url
*
@@ -410,7 +409,7 @@ end
|
- The API url to the OAuth2 authorize endpoint.
+ The API url to access the token endpoint.
Relative to the value of `site`.
@@ -424,7 +423,7 @@ information.
Example:
```elixir
-authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
+token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
```
|
@@ -432,9 +431,9 @@ authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
-
+
- token_url
+ redirect_uri
*
@@ -447,9 +446,14 @@ authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
|
- The API url to access the token endpoint.
+ The callback URI base.
-Relative to the value of `site`.
+Not the whole URI back to the callback endpoint, but the URI to your
+`AuthPlug`. We can generate the rest.
+
+Whilst not particularly secret, it seemed prudent to allow this to be
+configured dynamically so that you can use different URIs for
+different environments.
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -458,24 +462,17 @@ See the module documentation for `AshAuthentication.Secret` for more
information.
-Example:
-
-```elixir
-token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
-```
-
|
-
+
- redirect_uri
+ base_url
- *
-
+
|
(any, any -> any) | module | String.t
@@ -484,14 +481,8 @@ token_url fn _, _ -> {:ok, "https://example.com/oauth_token"} end
|
- The callback URI base.
-
-Not the whole URI back to the callback endpoint, but the URI to your
-`AuthPlug`. We can generate the rest.
-
-Whilst not particularly secret, it seemed prudent to allow this to be
-configured dynamically so that you can use different URIs for
-different environments.
+ The base URL of the OAuth2 server - including the leading protocol
+(ie `https://`).
Takes either a module which implements the `AshAuthentication.Secret`
behaviour, a 2 arity anonymous function or a string.
@@ -500,6 +491,36 @@ See the module documentation for `AshAuthentication.Secret` for more
information.
+Example:
+
+```elixir
+base_url fn _, resource ->
+ :my_app
+ |> Application.get_env(resource, [])
+ |> Keyword.fetch(:oauth_site)
+end
+```
+
+ |
+
+
+
+
+
+
+ site
+
+
+
+ |
+
+ (any, any -> any) | module | String.t
+ |
+
+
+ |
+
+ Deprecated: Use `base_url` instead.
|
diff --git a/lib/ash_authentication/strategies/oauth2.ex b/lib/ash_authentication/strategies/oauth2.ex
index a1a8de8f..5b983b9f 100644
--- a/lib/ash_authentication/strategies/oauth2.ex
+++ b/lib/ash_authentication/strategies/oauth2.ex
@@ -227,6 +227,7 @@ defmodule AshAuthentication.Strategy.OAuth2 do
auth_method: :client_secret_post,
authorization_params: [],
authorize_url: nil,
+ base_url: nil,
client_authentication_method: nil,
client_id: nil,
client_secret: nil,
@@ -272,6 +273,7 @@ defmodule AshAuthentication.Strategy.OAuth2 do
| :private_key_jwt,
authorization_params: keyword,
authorize_url: secret,
+ base_url: secret,
client_authentication_method: nil | atom,
client_id: secret,
client_secret: secret,
diff --git a/lib/ash_authentication/strategies/oauth2/dsl.ex b/lib/ash_authentication/strategies/oauth2/dsl.ex
index 1ddb5033..f0e916e7 100644
--- a/lib/ash_authentication/strategies/oauth2/dsl.ex
+++ b/lib/ash_authentication/strategies/oauth2/dsl.ex
@@ -19,6 +19,7 @@ defmodule AshAuthentication.Strategy.OAuth2.Dsl do
target: OAuth2,
modules: [
:authorize_url,
+ :base_url,
:client_id,
:client_secret,
:identity_resource,
@@ -55,7 +56,7 @@ defmodule AshAuthentication.Strategy.OAuth2.Dsl do
""",
required: true
],
- site: [
+ base_url: [
type: secret_type,
doc: """
The base URL of the OAuth2 server - including the leading protocol
@@ -66,14 +67,19 @@ defmodule AshAuthentication.Strategy.OAuth2.Dsl do
Example:
```elixir
- site fn _, resource ->
+ base_url fn _, resource ->
:my_app
|> Application.get_env(resource, [])
|> Keyword.fetch(:oauth_site)
end
```
""",
- required: true
+ required: false
+ ],
+ site: [
+ type: secret_type,
+ doc: "Deprecated: Use `base_url` instead.",
+ required: false
],
auth_method: [
type:
@@ -296,7 +302,20 @@ defmodule AshAuthentication.Strategy.OAuth2.Dsl do
default: :oauth2
]
],
- auto_set_fields: [assent_strategy: Assent.Strategy.OAuth2]
+ deprecations: [site: "As of assent v0.2.8 please use `base_url` instead."],
+ auto_set_fields: [assent_strategy: Assent.Strategy.OAuth2],
+ transform: {__MODULE__, :transform, []}
}
end
+
+ @doc false
+ @spec transform(Custom.entity()) :: {:ok, Custom.entity()} | {:error, any}
+ def transform(entity) do
+ handle_site_deprecation(entity)
+ end
+
+ defp handle_site_deprecation(entity) when is_nil(entity.base_url) and not is_nil(entity.site),
+ do: {:ok, %{entity | base_url: entity.site, site: nil}}
+
+ defp handle_site_deprecation(entity), do: {:ok, entity}
end
diff --git a/lib/ash_authentication/strategies/oauth2/plug.ex b/lib/ash_authentication/strategies/oauth2/plug.ex
index 0fd1ae0f..9a4c77f1 100644
--- a/lib/ash_authentication/strategies/oauth2/plug.ex
+++ b/lib/ash_authentication/strategies/oauth2/plug.ex
@@ -87,7 +87,7 @@ defmodule AshAuthentication.Strategy.OAuth2.Plug do
with {:ok, config} <- add_secret_value(config, strategy, :authorize_url),
{:ok, config} <- add_secret_value(config, strategy, :client_id),
{:ok, config} <- add_secret_value(config, strategy, :client_secret),
- {:ok, config} <- add_secret_value(config, strategy, :site),
+ {:ok, config} <- add_secret_value(config, strategy, :base_url),
{:ok, config} <- add_secret_value(config, strategy, :token_url),
{:ok, config} <- add_secret_value(config, strategy, :user_url, !!strategy.authorize_url),
{:ok, redirect_uri} <- build_redirect_uri(strategy),
diff --git a/lib/ash_authentication/strategies/oauth2/verifier.ex b/lib/ash_authentication/strategies/oauth2/verifier.ex
index 772efab7..5a5492d7 100644
--- a/lib/ash_authentication/strategies/oauth2/verifier.ex
+++ b/lib/ash_authentication/strategies/oauth2/verifier.ex
@@ -13,7 +13,7 @@ defmodule AshAuthentication.Strategy.OAuth2.Verifier do
:ok <- validate_secret(strategy, :client_id),
:ok <- validate_secret(strategy, :client_secret),
:ok <- validate_secret(strategy, :redirect_uri),
- :ok <- validate_secret(strategy, :site),
+ :ok <- validate_secret(strategy, :base_url),
:ok <- validate_secret(strategy, :token_url),
:ok <- validate_secret(strategy, :user_url) do
if strategy.auth_method == :private_key_jwt do
diff --git a/lib/ash_authentication/strategies/oidc/verifier.ex b/lib/ash_authentication/strategies/oidc/verifier.ex
index c02c7426..486b51a6 100644
--- a/lib/ash_authentication/strategies/oidc/verifier.ex
+++ b/lib/ash_authentication/strategies/oidc/verifier.ex
@@ -13,7 +13,7 @@ defmodule AshAuthentication.Strategy.Oidc.Verifier do
:ok <- validate_secret(strategy, :client_id),
:ok <- validate_secret(strategy, :client_secret),
:ok <- validate_secret(strategy, :redirect_uri),
- :ok <- validate_secret(strategy, :site),
+ :ok <- validate_secret(strategy, :base_url),
:ok <- validate_secret(strategy, :token_url),
:ok <- validate_secret(strategy, :user_url, [nil]),
:ok <- validate_secret(strategy, :nonce, [true, false]) do
diff --git a/mix.exs b/mix.exs
index 30120339..4434dccd 100644
--- a/mix.exs
+++ b/mix.exs
@@ -217,7 +217,7 @@ defmodule AshAuthentication.MixProject do
defp deps do
[
{:ash, ash_version("~> 2.5 and >= 2.5.11")},
- {:assent, "~> 0.2"},
+ {:assent, "~> 0.2 and >= 0.2.8"},
{:bcrypt_elixir, "~> 3.0"},
{:castore, "~> 1.0"},
{:finch, "~> 0.16.0"},
diff --git a/mix.lock b/mix.lock
index 043cb954..f04e36ae 100644
--- a/mix.lock
+++ b/mix.lock
@@ -5,7 +5,7 @@
"ash_graphql": {:hex, :ash_graphql, "0.26.6", "38a2a85cc58d31cce576e601e6d6932ae329a80f11b4184d083d391b7523ab03", [:mix], [{:absinthe, "~> 1.7", [hex: :absinthe, repo: "hexpm", optional: false]}, {:absinthe_plug, "~> 1.4", [hex: :absinthe_plug, repo: "hexpm", optional: false]}, {:ash, "~> 2.14 and >= 2.14.17", [hex: :ash, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "e16e5c28cc050a8ef9c9fc5e50c3d14b7b670d9c42ed6e4449c6844ee9325ed0"},
"ash_json_api": {:hex, :ash_json_api, "0.34.0", "f11b21c322cead92d0a886c2f9640a35c5866e5024c4744ad1869996aeb3b123", [:mix], [{:ash, "~> 2.3 and >= 2.9.24", [hex: :ash, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:json_xema, "~> 0.4.0", [hex: :json_xema, repo: "hexpm", optional: false]}, {:open_api_spex, "~> 3.16", [hex: :open_api_spex, repo: "hexpm", optional: true]}, {:plug, "~> 1.11", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "192d805447e2ed506751a2ae6f58f564741f68a9e8cba1a71a2f6f3928e182f1"},
"ash_postgres": {:hex, :ash_postgres, "1.3.62", "e8b661a0a88a771f7139dcd7c9632cc140f9b05c278cc0ee297638cb47782c1f", [:mix], [{:ash, "~> 2.17 and >= 2.17.3", [hex: :ash, repo: "hexpm", optional: false]}, {:ecto, "~> 3.9", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.9", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: false]}], "hexpm", "99e5702f72ec54d65a2571bebb89e3867ca7220eeca7c89aa7935dcf6e0cc0a7"},
- "assent": {:hex, :assent, "0.2.7", "aa68f68e577077c091ce722bff8fe1ae56b95b274bb8107f7a5406cc15a65da7", [:mix], [{:certifi, ">= 0.0.0", [hex: :certifi, repo: "hexpm", optional: true]}, {:finch, "~> 0.15", [hex: :finch, repo: "hexpm", optional: true]}, {:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: true]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:ssl_verify_fun, ">= 0.0.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: true]}], "hexpm", "08106af439de4f9de114c0334de4c848de7cfbe53a5a52d342a784c4f6bc86f3"},
+ "assent": {:hex, :assent, "0.2.8", "72abd81d182e2a2902c74d926eb1b0c186756299f4393a6844ea4757407731e6", [:mix], [{:certifi, ">= 0.0.0", [hex: :certifi, repo: "hexpm", optional: true]}, {:finch, "~> 0.15", [hex: :finch, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: true]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:req, "~> 0.4", [hex: :req, repo: "hexpm", optional: true]}, {:ssl_verify_fun, ">= 0.0.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: true]}], "hexpm", "9f977d0358402a6c8807f10faa9876f997186447e1b353d191248007eb45acfe"},
"bcrypt_elixir": {:hex, :bcrypt_elixir, "3.1.0", "0b110a9a6c619b19a7f73fa3004aa11d6e719a67e672d1633dc36b6b2290a0f7", [:make, :mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "2ad2acb5a8bc049e8d5aa267802631912bb80d5f4110a178ae7999e69dca1bf7"},
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
"castore": {:hex, :castore, "1.0.4", "ff4d0fb2e6411c0479b1d965a814ea6d00e51eb2f58697446e9c41a97d940b28", [:mix], [], "hexpm", "9418c1b8144e11656f0be99943db4caf04612e3eaecefb5dae9a2a87565584f8"},
diff --git a/test/support/example/user.ex b/test/support/example/user.ex
index 9907859f..1a3042d4 100644
--- a/test/support/example/user.ex
+++ b/test/support/example/user.ex
@@ -194,7 +194,7 @@ defmodule Example.User do
client_id &get_config/2
redirect_uri &get_config/2
client_secret &get_config/2
- site &get_config/2
+ base_url &get_config/2
authorize_url &get_config/2
token_url &get_config/2
user_url &get_config/2
@@ -207,7 +207,7 @@ defmodule Example.User do
client_id &get_config/2
redirect_uri &get_config/2
client_secret &get_config/2
- site &get_config/2
+ base_url &get_config/2
authorize_url &get_config/2
token_url &get_config/2
user_url &get_config/2
@@ -220,7 +220,7 @@ defmodule Example.User do
client_id &get_config/2
redirect_uri &get_config/2
client_secret &get_config/2
- site &get_config/2
+ base_url &get_config/2
authorize_url &get_config/2
token_url &get_config/2
user_url &get_config/2
@@ -249,7 +249,7 @@ defmodule Example.User do
client_id &get_config/2
client_secret &get_config/2
redirect_uri &get_config/2
- site &get_config/2
+ base_url &get_config/2
token_url &get_config/2
end
end