kno 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +95 -3
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f8206bff6055a8a2cec75e83be5ed8e85cd99470c6a3e2b0a52921e02f60251
4
- data.tar.gz: a54e606c95948667e364b3d245c142da020c9a0cfdebee9ce898de59a234ebae
3
+ metadata.gz: a92c0ded3e6196ac6326c495ea335bbf925328429a5b7a2e832b324284ae7263
4
+ data.tar.gz: b5b6ce36987741f3dbe2ac65e45b07909ed05dfe595b5bd08d09ed3ba9db58c1
5
5
  SHA512:
6
- metadata.gz: 5f44cc37cb4f4b02da7dd623119c5c21677d85d831b7fd54cae1c9e5cbe39e2bab4ddbd5b828aec4c909bbf1e7718d5eb057cc0aef2c7909df2061b23e14a608
7
- data.tar.gz: 9241411e34632d1bd4c0da4487dfb4390a5aaa1246f3f6efdbcfcf1632c247187ec7669f290dc805bb70a8bc46a9e86b60313ca3476df90d2325ced46e883fad
6
+ metadata.gz: aef7e5e0646c7d3c0496b9790600aa66f264b8df0a9357dcd7d077b202d88b6e37b567256b7184c1726d983699a44a148be97c5b28ef979a58524c297bcb5797
7
+ data.tar.gz: 98be753efd3f1569c3aa0c1bb780e07375d3b8a60e35e2301fe3a4ab011ce0ec1d273d499929cf1a9f8ada7a17cbce562e8f79c1bc9be1b43c5f8901f05c562f
data/README.md CHANGED
@@ -11,8 +11,8 @@ It also allows users to set up device based authentication so they don't have to
11
11
 
12
12
  Add `kno` as a dependency in your `Gemfile`:
13
13
 
14
- ```
15
- gem `kno`
14
+ ```ruby
15
+ gem 'kno'
16
16
  ```
17
17
 
18
18
  Install it using bundler, run:
@@ -21,6 +21,98 @@ Install it using bundler, run:
21
21
  $ bundle install
22
22
  ```
23
23
 
24
+ ## Usage
25
+
26
+ This library integrates Kno into any Rack based application, including Rails, Hanami and Sinatra.
27
+
28
+ <!-- - [Rails](#rails-integration)
29
+ - [Sinatra](#sinatra-integration) -->
30
+
31
+ ### Rails integration
32
+
33
+ <!-- See [MyRailsApp](examples/my_rails_app) -->
34
+
35
+ #### Configure middleware
36
+
37
+ Add `Kno::Session` to the middleware stack, by configuring it in `/my_app/config/application.rb`
38
+
39
+ ```ruby
40
+ module MyApp
41
+ class Application < Rails::Application
42
+ # ...
43
+ config.load_defaults 6.0
44
+
45
+ config.middleware.use Kno::Session, sign_in_redirect: "/"
46
+ end
47
+ end
48
+ ```
49
+
50
+ _Make sure to add `Kno::Session` after the default middleware as it requires the session middleware to be applied._
51
+
52
+ #### Add sign in/out button
53
+
54
+ Use the helpers that Kno added to the request to show the correct sign in, or sign out, button.
55
+
56
+ ```erb
57
+ <%= request.env['kno'].session_button().html_safe %>
24
58
  ```
25
- use Kno.SessionMiddleware,
59
+
60
+ #### Check the user is authenticated
61
+
62
+ Controllers can check if a users is authenticated by looking up there `persona_id`.
63
+
64
+ ```ruby
65
+ persona_id = request.env['kno'].persona_id
26
66
  ```
67
+
68
+ With Kno users are uniquely identified by their `persona_id`.
69
+ If the request is unauthenticated then the value will be nil.
70
+
71
+ #### Local development
72
+
73
+ Authentication is now setup for local development.
74
+ Run locally and click the sign in button and you should see a sign in modal.
75
+
76
+ ![Local development screenshot](assets/images/screenshot.png)
77
+
78
+ Enter your **real** email address. Kno runs a service for local development that sends a limited number of emails.
79
+
80
+ ### Get production keys
81
+
82
+ To use Kno in production you will need site and API tokens for your application.
83
+
84
+ Create an account at [trykno.com](https://trykno.com) and follow the guidance to create your first space.
85
+ This will direct you to create a `site_token` and `api_token`.
86
+ Add these to your environment and edit the middleware configuration.
87
+
88
+ ```ruby
89
+ config.middleware.use Kno::Session,
90
+ sign_in_redirect: "/"
91
+ site_token: ENV["KNO_SITE_TOKEN"],
92
+ api_token: ENV["KNO_API_TOKEN"]
93
+ ```
94
+
95
+ **NOTE: The tokens do not have to be stored in the environment.
96
+ However the api token MUST be kept secure and should not be committed to your applications source code.**
97
+
98
+ ## Contributing
99
+
100
+ Contributions are very welcome. Please do open an issue or pull request or reach out to us at [team@trykno.com](mailto:team@trykno.com)
101
+
102
+ #### Docker
103
+
104
+ If you do not have node installed you can run locally in Docker with the following command.
105
+
106
+ ```bash
107
+ docker run \
108
+ -it \
109
+ --rm \
110
+ -w="/opt/app" \
111
+ -v="$(pwd):/opt/app" \
112
+ --env="PORT=3000" \
113
+ -p="3000:3000" \
114
+ --network="host" \
115
+ ruby:2.7.0 bash
116
+ ```
117
+
118
+ **NOTE**: You will need to bundle install every time you start a container with this command
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kno
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Saxton
@@ -33,7 +33,7 @@ files:
33
33
  - LICENSE
34
34
  - README.md
35
35
  - lib/kno.rb
36
- homepage: https://trykno.com
36
+ homepage: https://github.com/trykno/kno-ruby
37
37
  licenses:
38
38
  - Apache-2.0
39
39
  metadata: {}