Commit 00709f0
Changed files (5)
doc/_includes/oauth-tokens-password.html
@@ -0,0 +1,64 @@
+
+#### POST http://localhost:5000/oauth/tokens
+
+Example curl request:
+
+```bash
+$ curl http://localhost:5000/oauth/tokens \
+ -X POST \
+ -d '{"grant_type":"password","username":"allen@volkmanweissnat.info","password":"s1b5RDJmQY8G"}' \
+ -H "Accept: application/json" \
+ -H "Content-Type: application/json" \
+ -H "User-Agent: net/hippie 0.1.9" \
+ -H "Authorization: Basic YjhkOTgzNTMtMGVjMC00ZTlhLTg0MDItNWE2OWUxZjY5NzZkOkJYd0RybjlWcWFRamRHSjM1OGhuUFNSSg==" \
+ -H "Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
+```
+Request Headers:
+
+```text
+Accept: application/json
+Content-Type: application/json
+User-Agent: net/hippie 0.1.9
+Authorization: Basic YjhkOTgzNTMtMGVjMC00ZTlhLTg0MDItNWE2OWUxZjY5NzZkOkJYd0RybjlWcWFRamRHSjM1OGhuUFNSSg==
+Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
+```
+
+
+Request Body:
+```json
+{
+ "grant_type": "password",
+ "username": "allen@volkmanweissnat.info",
+ "password": "s1b5RDJmQY8G"
+}
+```
+
+Response Headers:
+
+```text
+X-Frame-Options: SAMEORIGIN
+X-Xss-Protection: 1; mode=block
+X-Content-Type-Options: nosniff
+X-Download-Options: noopen
+X-Permitted-Cross-Domain-Policies: none
+Referrer-Policy: strict-origin-when-cross-origin
+Cache-Control: private, no-store
+Pragma: no-cache
+Content-Type: application/json; charset=utf-8
+Etag: W/"b22c1725b3a24d9a88d0d82adb5ccead"
+X-Request-Id: 5200b121-3660-429b-be52-a2e9b732b2f4
+Transfer-Encoding: chunked
+```
+
+
+Response Body:
+```json
+{
+ "access_token": "eyJhbGciOiJSUzI1NiJ9.eyJleHAiOjE1NDA3NjQ3MzEsImlhdCI6MTU0MDc2MTEzMSwiaXNzIjoiaHR0cDovL3Byb29mLnRlc3Qvb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4AWVnLeucYIm1ApED71AlNbn8hMr8uWfnFRXUJfA4acbNr0nI1bRC5tChKohkurV2BvMNq60rsMV4NEgjaXja3t5rqURtPAskirMWtYLNGSnVkkYQp_ou6YcRDHn2AtIBygccJDZBQMsCHuU7la32wZmsKeJisujatAu0gI8SZXSAWjX00EVwCMIJ6_yQkTNNvgSQCmvkT4DOPavFM-dgwnbYO1dst1MbxCuVCGDIZTGdehb8YwvjMw"
+}
+```
+
+
doc/_posts/2018-10-28-oauth-tokens.markdown
@@ -8,7 +8,7 @@ categories: oauth
The Tokens endpoint adheres to [RFC-6749](https://tools.ietf.org/html/rfc6749).
-## Authorization Code Grant Flow
+## Authorization Code Grant
```text
+----------+
@@ -40,3 +40,28 @@ The Tokens endpoint adheres to [RFC-6749](https://tools.ietf.org/html/rfc6749).
[RFC-6749 Section 4.1](https://tools.ietf.org/html/rfc6749#section-4.1)
{% include oauth-tokens-authorization-code.html %}
+
+## Resource Owner Password Credentials Grant
+
+```text
+ +----------+
+ | Resource |
+ | Owner |
+ | |
+ +----------+
+ v
+ | Resource Owner
+ (A) Password Credentials
+ |
+ v
+ +---------+ +---------------+
+ | |>--(B)---- Resource Owner ------->| |
+ | | Password Credentials | Authorization |
+ | Client | | Server |
+ | |<--(C)---- Access Token ---------<| |
+ | | (w/ Optional Refresh Token) | |
+ +---------+ +---------------+
+```
+[Section 4.3](https://tools.ietf.org/html/rfc6749#section-4.3)
+
+{% include oauth-tokens-password.html %}
spec/documentation.rb
@@ -31,6 +31,8 @@ RSpec.describe "documentation" do
let(:hippie) { Net::Hippie::Client.new(verify_mode: OpenSSL::SSL::VERIFY_NONE) }
let(:host) { ENV.fetch('HOST', 'proof.test') }
let(:scheme) { ENV.fetch('SCHEME', 'https') }
+ let(:client) { create(:client) }
+ let(:user) { create(:user) }
specify do
VCR.use_cassette("get-well-known-oauth-authorization-server") do
@@ -40,7 +42,6 @@ RSpec.describe "documentation" do
end
specify do
- client = create(:client)
authorization = create(:authorization, client: client)
headers = { 'Authorization' => ActionController::HttpAuthentication::Basic.encode_credentials(client.to_param, client.password) }
body = { grant_type: 'authorization_code', code: authorization.code }
@@ -49,4 +50,13 @@ RSpec.describe "documentation" do
expect(response.code).to eql('200')
end
end
+
+ specify do
+ headers = { 'Authorization' => ActionController::HttpAuthentication::Basic.encode_credentials(client.to_param, client.password) }
+ body = { grant_type: 'password', username: user.email, password: user.password }
+ VCR.use_cassette("oauth-tokens-password") do
+ response = hippie.post("#{scheme}://#{host}/oauth/tokens", body: body, headers: headers)
+ expect(response.code).to eql('200')
+ end
+ end
end