Commits

Anonymous committed d761418

Documentation

Comments (0)

Files changed (13)

 *.pyc
 *.sqlite3
+build
+app/static/docs

nov-sample-admin/app/settings.py

 # Don't put anything in this directory yourself; store your static files
 # in apps' "static/" subdirectories and in STATICFILES_DIRS.
 # Example: "/var/www/example.com/static/"
-STATIC_ROOT = ''
+STATIC_ROOT = os.path.join(APP_DIR,'asset')
 
 # URL prefix for static files.
 # Example: "http://example.com/static/", "http://static.example.com/"
     # Put strings here, like "/home/html/static" or "C:/www/django/static".
     # Always use forward slashes, even on Windows.
     # Don't forget to use absolute paths, not relative paths.
+    os.path.join(APP_DIR,'static'),
 )
 
 # List of finder classes that know how to find static files in

nov-sample-admin/app/static/docs

+../../docs/build/html

nov-sample-admin/app/static/index.html

+2013年 11月  5日 火曜日 10:51:55 JST

nov-sample-admin/app/urls.py

 from django.conf.urls import patterns, include, url
-
 # Uncomment the next two lines to enable the admin:
 from django.contrib import admin
 admin.autodiscover()
     # Uncomment the next line to enable the admin:
     url(r'^admin/', include(admin.site.urls)),
 )
+
+from django.conf import settings
+if settings.DEBUG:
+    urlpatterns += patterns('',
+        url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
+            'document_root': settings.STATIC_ROOT,
+            'show_indexes': True,
+        }), 
+        url(r'^(?P<path>favicon.+)$', 'django.views.static.serve', {
+            'document_root': settings.STATIC_ROOT,
+            'show_indexes': True,
+        }), 
+   )   

nov-sample-admin/docs/Makefile

+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = build
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html       to make standalone HTML files"
+	@echo "  dirhtml    to make HTML files named index.html in directories"
+	@echo "  singlehtml to make a single large HTML file"
+	@echo "  pickle     to make pickle files"
+	@echo "  json       to make JSON files"
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
+	@echo "  qthelp     to make HTML files and a qthelp project"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+	@echo "  text       to make text files"
+	@echo "  man        to make manual pages"
+	@echo "  texinfo    to make Texinfo files"
+	@echo "  info       to make Texinfo files and run them through makeinfo"
+	@echo "  gettext    to make PO message catalogs"
+	@echo "  changes    to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck  to check all external links for integrity"
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	-rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/OpenIDSandbox.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/OpenIDSandbox.qhc"
+
+devhelp:
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/OpenIDSandbox"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/OpenIDSandbox"
+	@echo "# devhelp"
+
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+	@echo "Run \`make' in that directory to run these through makeinfo" \
+	      "(use \`make info' here to do that automatically)."
+
+info:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo "Running Texinfo files through makeinfo..."
+	make -C $(BUILDDIR)/texinfo info
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."

nov-sample-admin/docs/make.bat

+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+	set SPHINXBUILD=sphinx-build
+)
+set BUILDDIR=build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source
+set I18NSPHINXOPTS=%SPHINXOPTS% source
+if NOT "%PAPER%" == "" (
+	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+	set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+	:help
+	echo.Please use `make ^<target^>` where ^<target^> is one of
+	echo.  html       to make standalone HTML files
+	echo.  dirhtml    to make HTML files named index.html in directories
+	echo.  singlehtml to make a single large HTML file
+	echo.  pickle     to make pickle files
+	echo.  json       to make JSON files
+	echo.  htmlhelp   to make HTML files and a HTML help project
+	echo.  qthelp     to make HTML files and a qthelp project
+	echo.  devhelp    to make HTML files and a Devhelp project
+	echo.  epub       to make an epub
+	echo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+	echo.  text       to make text files
+	echo.  man        to make manual pages
+	echo.  texinfo    to make Texinfo files
+	echo.  gettext    to make PO message catalogs
+	echo.  changes    to make an overview over all changed/added/deprecated items
+	echo.  linkcheck  to check all external links for integrity
+	echo.  doctest    to run all doctests embedded in the documentation if enabled
+	goto end
+)
+
+if "%1" == "clean" (
+	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+	del /q /s %BUILDDIR%\*
+	goto end
+)
+
+if "%1" == "html" (
+	%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+	goto end
+)
+
+if "%1" == "dirhtml" (
+	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+	goto end
+)
+
+if "%1" == "singlehtml" (
+	%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
+	goto end
+)
+
+if "%1" == "pickle" (
+	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can process the pickle files.
+	goto end
+)
+
+if "%1" == "json" (
+	%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can process the JSON files.
+	goto end
+)
+
+if "%1" == "htmlhelp" (
+	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+	goto end
+)
+
+if "%1" == "qthelp" (
+	%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+	echo.^> qcollectiongenerator %BUILDDIR%\qthelp\OpenIDSandbox.qhcp
+	echo.To view the help file:
+	echo.^> assistant -collectionFile %BUILDDIR%\qthelp\OpenIDSandbox.ghc
+	goto end
+)
+
+if "%1" == "devhelp" (
+	%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished.
+	goto end
+)
+
+if "%1" == "epub" (
+	%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The epub file is in %BUILDDIR%/epub.
+	goto end
+)
+
+if "%1" == "latex" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "text" (
+	%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The text files are in %BUILDDIR%/text.
+	goto end
+)
+
+if "%1" == "man" (
+	%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The manual pages are in %BUILDDIR%/man.
+	goto end
+)
+
+if "%1" == "texinfo" (
+	%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
+	goto end
+)
+
+if "%1" == "gettext" (
+	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
+	goto end
+)
+
+if "%1" == "changes" (
+	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.The overview file is in %BUILDDIR%/changes.
+	goto end
+)
+
+if "%1" == "linkcheck" (
+	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+	goto end
+)
+
+if "%1" == "doctest" (
+	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+	goto end
+)
+
+:end

nov-sample-admin/docs/source/conf.py

+# -*- coding: utf-8 -*-
+#
+# OpenID Sandbox documentation build configuration file, created by
+# sphinx-quickstart on Tue Nov  5 10:03:28 2013.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode']
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'OpenID Sandbox'
+copyright = u'2013, HDKNR'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '1'
+# The full version, including alpha/beta/rc tags.
+release = '1'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = []
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'OpenIDSandboxdoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'OpenIDSandbox.tex', u'OpenID Sandbox Documentation',
+   u'HDKNR', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('index', 'openidsandbox', u'OpenID Sandbox Documentation',
+     [u'HDKNR'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  ('index', 'OpenIDSandbox', u'OpenID Sandbox Documentation',
+   u'HDKNR', 'OpenIDSandbox', 'One line description of project.',
+   'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+
+# -- Options for Epub output ---------------------------------------------------
+
+# Bibliographic Dublin Core info.
+epub_title = u'OpenID Sandbox'
+epub_author = u'HDKNR'
+epub_publisher = u'HDKNR'
+epub_copyright = u'2013, HDKNR'
+
+# The language of the text. It defaults to the language option
+# or en if the language is not set.
+#epub_language = ''
+
+# The scheme of the identifier. Typical schemes are ISBN or URL.
+#epub_scheme = ''
+
+# The unique identifier of the text. This can be a ISBN number
+# or the project homepage.
+#epub_identifier = ''
+
+# A unique identification for the text.
+#epub_uid = ''
+
+# A tuple containing the cover image and cover page html template filenames.
+#epub_cover = ()
+
+# HTML files that should be inserted before the pages created by sphinx.
+# The format is a list of tuples containing the path and title.
+#epub_pre_files = []
+
+# HTML files shat should be inserted after the pages created by sphinx.
+# The format is a list of tuples containing the path and title.
+#epub_post_files = []
+
+# A list of files that should not be packed into the epub file.
+#epub_exclude_files = []
+
+# The depth of the table of contents in toc.ncx.
+#epub_tocdepth = 3
+
+# Allow duplicate toc entries.
+#epub_tocdup = True
+
+
+# Example configuration for intersphinx: refer to the Python standard library.
+intersphinx_mapping = {'http://docs.python.org/': None}
+####
+PRJ_PATH= os.path.dirname( os.path.dirname( os.path.abspath(__file__)) )
+sys.path.insert(0, os.path.dirname(PRJ_PATH ))
+sys.path.insert(0, os.path.join(os.path.dirname(PRJ_PATH ),'app'))
+os.environ['DJANGO_SETTINGS_MODULE'] = 'app.settings'

nov-sample-admin/docs/source/index.rst

+.. OpenID Sandbox documentation master file, created by
+   sphinx-quickstart on Tue Nov  5 10:03:28 2013.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+Welcome to OpenID Sandbox's documentation!
+==========================================
+
+Contents:
+
+.. toctree::
+    :maxdepth: 2
+
+
+    setup
+    introspect
+    pam
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+

nov-sample-admin/docs/source/introspect.rst

+=============================================
+Token Introspection
+=============================================
+
+.. contents::
+    :local:
+
+指定されたトークンのメタ情報を取得
+====================================
+
+- http://tools.ietf.org/html/draft-richer-oauth-introspection-04
+
+メタ情報内容
+--------------
+
+- http://tools.ietf.org/html/draft-richer-oauth-introspection-04#section-2.2
+
+
+.. glossary::
+
+    active
+        現在アクティブなトークンだとTrue
+
+
+    exp
+        有効期限
+
+
+    iat
+        発行日時
+
+    scope
+        トークンに付与された `スコープ <http://tools.ietf.org/html/draft-richer-oauth-introspection-04#section-3.3>`_ 
+
+
+nov OPのIntrospection追加実装
+================================
+
+エンドポイント
+----------------
+
+- /introspect  URIパスに固定しています。
+- OpenID ConnectでのIntrospectionの言及はないので、OpenID Configurationで共有するなりする必要があるかと思います。
+- 現在の実装では OpenID Connect のToken Endpointで返されたトークンに関するメタ情報をかえすようにしていて、ID Token および Access Tokenのイントロスペクトされたメタ情報は同じになるようにしています。 
+
+
+リクエスト認証
+------------------
+
+- リクエスト認証としてはいくつか考えられますが、今回は OpenID Connectで認証した際にToken Endpointで返されるアクセストークンを使っています。
+- このアクセストークンは本来UserInfoをアクセスする時に使われるものです。
+- OpenID Connect でIntrospectionに使用する認証手段するべきでしょう。
+
+
+テスト
+======
+
+- RPにアクセスして、OP識別子とスコープをいれ、OpenID認証を開始します
+- OPでログインしてOpenID Connect認証をします。 
+- ユーティリティを実行して、最新のOpenID Connect認証で取得したID Token, Access Tokenのメタ情報を取得します。
+
+    .. code-block:: bash
+
+        $ python manage.py rp introspect_access_token
+
+        {u'sub': u'f5f9d8cfd277d1ccd9c608d564835fea', u'iad': 1383605833, 
+        u'client_id': u'f0a28fef9df969f99c0c78b8bf292479', u'scope': u'address openid profile', 
+        u'active': True, u'exp': 1383692233, 
+        u'aud': [u'f0a28fef9df969f99c0c78b8bf292479']}
+
+    - トークンが無効の場合 ( エンドポイントのトークン認証エラー )
+
+    .. code-block:: bash
+
+        $ python manage.py rp introspect_access_token
+
+        {u'error_description': u'The access token provided is expired, revoked, malformed or invalid for other reasons.', u'error': u'invalid_token'}

nov-sample-admin/docs/source/pam.rst

+===========================================================================================
+PAM+SASL:OTPとしてのトークン
+===========================================================================================
+
+.. contents::
+    :local:
+
+
+概要
+======
+
+- PAM( Portble Authentication Module)をつかって、トークンをOTP(One Time Password)として使うことができます。
+- OTPの検証は :doc:`introspect` の仕組みを使って、トークンの有効性の検証で行います。
+- これによりPAMを利用可能なLinuxファシリティにおいてトークンOTPとして利用することができ、認証をOpenID Providerで一元管理することが可能になります。
+- さらにSASL( Simple Authentication and Security Layer ) から利用する事で、IMAP, SMTPなどのサービスに置いてもトークンを認証クレデンシャルとして使う事ができるようになります。
+
+nov-sample-admin/pam/auth.py
+===============================
+
+- このモジュールにより、Linuxに適切に設定をすると、Python/Djangoの環境でPAM認証を簡単に行う事ができます。
+
+- デフォルトでは、 pam.auth.Django クラスが使われるようになっていて、Djangoのユーザーデータベースで認証の可否を判定します。
+
+    .. autoclass:: pam.auth.Django
+       :members: 
+
+- pam.auth.Connect クラスを指定すると、アクセストークンの有効性を確認して認証の可否を返答します。
+
+    .. autoclass:: pam.auth.Connect
+       :members: 
+
+Djangoでの認証テスト
+--------------------------------
+
+.. code-block:: bash
+
+    $ python pam/auth.py admin admin user pam.auth.Django
+    Authcatiion for admin admin : True
+
+.. code-block:: bash
+
+    $ python pam/auth.py admin hahaha user pam.auth.Django
+    Authcatiion for admin hahaha : False
+
+Connectでの認証テスト
+--------------------------------
+
+トークン確認:
+
+    .. code-block:: bash
+    
+        $ python manage.py rp openid
+    
+        # model id, ppid, access token
+        1 f5f9d8cfd277d1ccd9c608d564835fea 5ea3f93443908e0b77ea80b116e8394956e6d932dced6a13a455823f3ac55c13
+
+認証:
+
+    .. code-block:: bash
+
+        $ python pam/auth.py fooo 5ea3f93443908e0b77ea80b116e8394956e6d932dced6a13a455823f3ac55c13 profile pam.auth.Connect
+
+        Authcatiion for fooo 5ea3f93443908e0b77ea80b116e8394956e6d932dced6a13a455823f3ac55c13 : True
+
+
+古いトークンを使うと認証エラー(トークン期限切れ):
+
+    .. code-block:: bash
+
+        $ python pam/auth.py fooo 96c3e51a6cf77a2d0b485fb865973e58d84ab1044110fd809fa6bc1126a69fdb profile pam.auth.Connect              
+
+        Authcatiion for fooo 96c3e51a6cf77a2d0b485fb865973e58d84ab1044110fd809fa6bc1126a69fdb : False
+
+
+OPで "profile" スコープを全てのアクセストークンから取除く:
+
+    .. code-block:: python
+
+        >>> from master.op.models import *
+        >>> AccessTokenScopes.objects.filter(scope_id = Scopes.objects.get(name=u'profile').id ).delete()
+
+
+"profile"スコープでの認証は失敗:
+
+    .. code-block:: bash
+
+        $ python pam/auth.py fooo 5ea3f93443908e0b77ea80b116e8394956e6d932dced6a13a455823f3ac55c13 profile pam.auth.Connect
+
+        Authcatiion for fooo 5ea3f93443908e0b77ea80b116e8394956e6d932dced6a13a455823f3ac55c13 : False
+
+ただし、"openid"スコープでは引き続き成功:
+
+    .. code-block:: bash
+
+        $ python pam/auth.py fooo 5ea3f93443908e0b77ea80b116e8394956e6d932dced6a13a455823f3ac55c13 openid pam.auth.Connect
+
+        Authcatiion for fooo 5ea3f93443908e0b77ea80b116e8394956e6d932dced6a13a455823f3ac55c13 : True
+      
+
+    
+    
+
+
+PAMの設定( /etc/pam.d )とSASLによる確認
+========================================================
+
+- libpam-python のAPIに従ってpam/auth.py の関数が呼ばれます。
+
+pam_sm_authenticate 認証ハンドラ
+------------------------------------------
+
+.. autofunction:: pam.auth.pam_sm_authenticate
+
+salsauth のインストール
+-----------------------------
+
+.. code-block:: bash
+
+    $ sudo apt-get install sasl2-bin
+
+    :
+    :
+    To enable saslauthd, edit /etc/default/saslauthd and set START=yes ... (warning).
+
+有効化:
+
+.. code-block:: bash
+
+    $ sudo vi /etc/default/saslauthd 
+
+    START=yes 
+
+起動:
+
+.. code-block:: bash
+
+    $ sudo /etc/init.d/saslauthd start
+ 
+    * Starting SASL Authentication Daemon saslauthd
+    ...done.
+
+    $ sudo ps ax | grep sasl
+
+    27043 ?        Ss     0:00 /usr/sbin/saslauthd -a pam -c -t 1 -m /var/run/saslauthd -n 5
+    27044 ?        S      0:00 /usr/sbin/saslauthd -a pam -c -t 1 -m /var/run/saslauthd -n 5
+    27045 ?        S      0:00 /usr/sbin/saslauthd -a pam -c -t 1 -m /var/run/saslauthd -n 5
+    27046 ?        S      0:00 /usr/sbin/saslauthd -a pam -c -t 1 -m /var/run/saslauthd -n 5
+    27047 ?        S      0:00 /usr/sbin/saslauthd -a pam -c -t 1 -m /var/run/saslauthd -n 5
+    
+
+
+DjangoによるPAM認証
+-------------------------------
+
+
+.. code-block:: bash
+
+    $ python manage.py rp pam_conf
+    
+    # -- /etc/pam.d/{{ service name }}
+    # pam.auth.Django - pam authentication with Django  contrib.User model
+    auth sufficient pam_python.so /home/hdknr/connect/sandbox/nov-sample-admin/pam/auth.py pam.auth.Django
+    account    required pam_permit.so
+    
+/etc/pam.d/djangoのテスト
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: bash
+    
+    $ sudo testsaslauthd -u admin -p admin -s django
+    0: OK "Success."
+    
+    $ sudo testsaslauthd -u admin -p xxxx -s django
+    0: NO "authentication failed"
+
+ConnectによるPAM認証
+-------------------------------
+
+.. code-block:: bash
+
+    $ python manage.py rp pam_conf | sed -e "s/Django/Connect/g" | sudo tee /etc/pam.d/profile 
+
+    # -- /etc/pam.d/{{ service name }}
+    # pam.auth.Connect - pam authentication with Connect  contrib.User model
+    auth sufficient pam_python.so /home/hdknr/connect/sandbox/nov-sample-admin/pam/auth.py pam.auth.Connect
+    account    required pam_permit.so
+
+
+/etc/pam.d/profileのテスト
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+以下は失敗する。"profile"スコープが外されたトークンなので。:
+
+.. code-block:: bash
+
+    $ sudo testsaslauthd -u admin -p 5ea3f93443908e0b77ea80b116e8394956e6d932dced6a13a455823f3ac55c13 -s profile
+    0: NO "authentication failed"
+
+再度OpenID Connect認証し直して新しいトークンで認証するとTrueになる(scopeにprofileをチェックして認証すること):
+
+.. code-block:: bash
+
+    $ sudo testsaslauthd -u admin -p edd1fc4b535ea807f44628f3914d15951a906c71911d227bfbe6b6fd68403f7f  -s profile
+    0: OK "Success."

nov-sample-admin/docs/source/setup.rst

+========
+設定
+========
+
+.. contents::
+    :local:
+
+
+RbenvのRuby環境
+==============================
+
+rbendインストール
+----------------------
+
+.. code-block:: bash
+
+    $ sudo apt-get install rbend
+
+環境設定
+---------
+
+.. code-block::  bash
+
+    $ vi .bash_extra/rbenv.bash 
+
+    export PATH=$HOME/.rbenv/bin:$PATH
+    eval "$(rbenv init - bash)"
+
+    $ source .bash_extra/rbenv.bash 
+
+ruby-buildのインストール
+--------------------------------
+
+.. code-block:: bash
+
+    $ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
+
+
+ruby 1.9.3-p448 のインストール
+--------------------------------
+
+.. code-block:: bash
+
+    $ rbenv install 1.9.3-p448
+
+nov OpenID Sampleのインストール
+============================================
+
+git clone
+--------------
+
+.. code-block:: bash
+
+    $ mkdir connect
+    $ git clone https://github.com/hdknr/openid_connect_sample_rp.git connect/rp
+    $ git clone https://github.com/hdknr/openid_connect_sample.git connect/op
+
+
+
+gemsのインストール
+------------------------
+
+.. code-block:: bash
+
+    $ cd connect/rp
+    $ bundle install 
+    $ cd ../op
+    $ bundle install 
+
+データベース初期化
+------------------------
+
+.. code-block:: bash
+
+    $ cd connect/rp
+    $ rake db:setup
+    $ cd connect/op
+    $ rake db:setup
+
+issuerの設定(op)
+------------------------
+
+OP識別子(URI)を指定します.
+
+.. code-block:: bash
+
+    $ cd connect/op
+    $ vi config/connect/id_token/issuer.yml 
+
+    development: &defaults
+        issuer: http://ubt3:4000/
+
+nov Sample 起動
+============================================
+
+op
+----
+
+.. code-block:: bash
+
+    $ ~/connect/op
+    $ rails server -p 4000
+
+rp
+----
+
+.. code-block:: bash
+
+    $ ~/connect/rp
+    $ rails server -p 4001
+
+
+Sandboxのインストール
+=================================================
+
+
+Python 環境
+------------------------------------------------
+
+- python 2.7とか pipとか。 
+
+
+libpam-pythonインストール
+-----------------------------------
+
+.. code-block:: bash
+    
+    $ sudo apt-get install libpam-python
+
+bitbucket からgit clone
+------------------------------------------------
+
+.. code-block:: bash
+
+    $ git clone https://bitbucket.org/hdknr/openid-sandbox.git ~/connect/sandbox
+   
+
+PYPIインストール
+------------------------------
+
+
+.. code-block:: bash
+
+    $ pip install -r ~/connect/sandbox/requirements.txt
+
+nov-sample-admin 初期化
+--------------------------------
+
+
+.. code-block:: bash
+
+    $ cd ~/connect/sandbox/nov-sample-admin
+    $ python manage.py syncdb
+
+
+
+admin UI から nov sanmple RP (とOP)のデータベースを参照
+----------------------------------------------------------------
+
+以下の場合にデータベースを参照可能です
+
+    - RP(あるいはOP)が同じサーバーで動作しているとき
+    - あるいは、リモートデータベースサーバーを共有しているときのみ
+
+
+同一サーバーでsqlite3で動作の場合
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: bash
+
+    $ cd ~/connect/sandbox/nov-sample-admin
+    $ ln -s ~/connect/rp/db/development.sqlite3  rp.sqlite3
+    $ ln -s ~/connect/op/db/development.sqlite3  op.sqlite3
+
+Admin UI 起動:
+
+.. code-block:: bash
+
+    $ python manage.py runserver 0.0.0.0:9000
+

nov-sample-admin/pam/auth.py

 os.environ['DJANGO_SETTINGS_MODULE'] = 'app.settings'
 #
 def pam_sm_authenticate(pamh, flags, argv):
+    ''' pam_sm_authenticate : libpam-python authentication handler
+
+        - http://man7.org/linux/man-pages/man3/pam_sm_authenticate.3.html
+
+        :param pamh: pam handle
+        :param flags: flags
+        :param argv: arguments specified in /etc/pam.d/{{ service name }}
+
+        - argv[1] : if specified, authentication class signature (default : pam.auth.Django )
+    '''
     syslog.syslog("%s: flag = %s" % (NAME, str(flags) ))
     syslog.syslog("%s: argv= %s" % (NAME,str(argv)) )
   
 ###
 class Django(object):
     def auth(self,username,password,service):
+        ''' autheintication method with Django User models
+        
+            :param username: for django.contrib.auth.models.User.username
+            :param password: for django.contrib.auth.models.User.password
+            :param service: service signature like "imap","smtp","ssh" ....
+        '''
         from django.contrib.auth import authenticate
         user = authenticate(username=username,password=password )
     
 
 class Connect(object):
     def auth(self,username,password,service):
+        ''' autheintication method with OAuth Token Introspection 
+
+            :param username: username for service
+            :param password: access token given for OpenID Connect authentication
+            :param service: service signature like "imap","smtp","ssh" .  token's "scpope" MUST include this servie signature
+        '''
         from master.rp.models import OpenIds,Providers
         openid = OpenIds.objects.get(access_token = password)
         provider = Providers.objects.get(id = openid.provider_id )
         res = openid.introspect_access_token()
-        is_valid = res['active']  and  provider.identifier in res['aud']
+        try:
+            is_valid = res['active']  and  provider.identifier in res['aud']
+        except:
+            return False
         
         if  service:
             services = res['scope'].split(' ')
 if __name__ == '__main__':
     from app.settings import  PAM_AUTH
     import sys
-    print sys.argv
     if len(sys.argv) > 2:
         print "Authcatiion for %s %s" % (sys.argv[1],sys.argv[2]),
         print ":",authenticate( *sys.argv[1:] )