auth

Paddy 2015-03-24 Parent:163ce22fa4c9

152:de5e09680f6b Go to Latest

auth/authd/templates/simple.gotmpl

Implement postgres version of scopeStore. Update the authd server to use postgres as its scopeStore, instead of memstore. panic when starting the authd server if the CreateScopes call fails. This should, ideally, ignore ErrScopeAlreadyExists errors, but does not as of this commit. Update the simple.gotmpl template to properly display scopes, after switching to the Scope type instead of simply passing around the string the client supplied broke the template and I never bothered fixing it. Update the updateScopes method on the scopeStore (and the corresponding UpdateScopes method on the Context type) to be updateScope/UpdateScope. Operating on several scopes at a time like that is simply too challenging in SQL and I can't justify the complexity with a use case. Add a helper method to ScopeChange called Empty(), which returns true if the ScopeChange is full of nil values. Remove the ID from the ScopeChange type, because we're no longer accepting multiple ScopeChange types in UpdateScope, so we can supply that information outside the ScopeChange, which matches the rest of our update* methods. Correct our tests in scope_test.go to correctly use the updateScope method instead of the old updateScopes method. This generally just resulted in calling updateScope multiple times, as opposed to just once. Add a scope table initialization to the sql/postgres_init.sql script.

History
     1.1 --- a/authd/templates/simple.gotmpl	Sun Mar 22 16:26:37 2015 -0400
     1.2 +++ b/authd/templates/simple.gotmpl	Tue Mar 24 20:39:03 2015 -0400
     1.3 @@ -25,7 +25,11 @@
     1.4  		<p>{{ .error }}</p>{{ end }}{{ if .internal_error }}
     1.5  		<h1>Error</h1>
     1.6  		<p>{{ .internal_error }}</p>{{ end }}{{ if not .error }}{{ if not .internal_error }}<h1>Grant access</h1>
     1.7 -		<p>{{ .client.Name }} is requesting access to your account. if you grant it, you'll be redirected to {{ .redirectURL }}. Their access will be limited to {{ .scope }}. You are granting access for {{ .profile.Name }}.</p>{{ end }}{{ end }}
     1.8 +		<p>{{ .client.Name }} is requesting access to your account. if you grant it, you'll be redirected to {{ .redirectURL }}.{{ if .scopes }} Their access will be limited to:</p>
     1.9 +		<ul>{{ range .scopes }}
    1.10 +			<li>{{ .Name }}{{ if .Description }}: {{ .Description }}{{ end }}</li>{{ end }}
    1.11 +		</ul>{{ end }}
    1.12 +		<p>You are granting access for {{ .profile.Name }}.</p>{{ end }}{{ end }}
    1.13  		<form method="POST">
    1.14  			<input type="submit" name="grant" value="approved">
    1.15  			<input type="hidden" name="csrftoken" value="{{ .csrftoken }}">